iOS Development UI Basics-handwriting controls, Frame,center and bounds properties

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.