1. Steps of the handwriting control (1) Use the corresponding control class to create the control object (2) to set the various properties of the control (3) Add the control to the view (4) If the control is a button, you also need to consider the control's Click event (5) Note: View Contollor and view relationships 2.1frame, center, and bounds Properties frame: Control position and Size Center: Control position (center point) Bounds: Control size (in its own upper left corner as the origin) 2.2. Attention Point
(1) The position of the control can be modified by the following properties
Frame.origin
Center
(2) The size of the control can be modified by the following properties
Frame.size
Bounds.size
3.1 Main properties and methods
Handwriting Control Code 37//One, write a button control, there is a picture 38 39//1. Create a button object using a class//UIButton *headbtn=[[uibutton alloc] Initwithf Rame:cgrectmake (100, 100, 100, 100)]; 41//Set button object for custom type UIButton *headbtn=[uibutton Buttonwithtype:uibuttontypecustom]; 43 44//2. Set the properties of the object 45//(1) Location, etc. universal property settings Headbtn.frame=cgrectmake (100, 100, 100, 100); 47 48//(2) Set the properties of the button in the normal state [headbtn setbackgroundimage:[uiimage imagenamed:@ "I"] Forstate:uicontrolstatenorma L]; [headbtn settitle:@] dot me! [Forstate:uicontrolstatenormal]; Wuyi [headbtn Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatenormal]; 52 53//(3) Set the properties of the button in the Highlight state [headbtn setbackgroundimage:[uiimage imagenamed:@ "a"] Forstate:uicontrolstatehighl Ighted]; [Headbtn settitle:@] is OK ~ "forstate:uicontrolstatehighlighted"; [Headbtn Settitlecolor:[uicolor Bluecolor] forstate:uicontrolstatehighlighted]; 57 58//3. Add the object to the view and show it. [Self.view addsubview:headbtn]; 60//Attention point! SELF.HEADIMAGEVIEW=HEADBTN;
4. Click Control event for Button [topbtn addtarget:self Action: @selector (click:) forcontrolevents:uicontroleventtouchupinside] ;
iOS Development UI Basics-handwriting controls, Frame,center and bounds properties