IOS-control view and button, ios control viewbutton

Source: Internet
Author: User

IOS-control view and button, ios control viewbutton
IBAction and IBOutlet

IBAction is the return value, which is equivalent to void. Only the return value is the IBAction method can be connected to the control in storyboard.

Only the property declared as IBOutlet can be connected to the control in storyboard. <喎? kf ware vc " target="_blank" class="keylink"> Vc3Ryb25nPjxiciAvPg0KPGltZyBhbHQ9 "write the image description here" src = "/uploadfile/Collfiles/20180228/201802280933431059 .png" title =" \ "/>
To make sure that the control is not modified elsewhere, convert it to a private variable and place it in the. m file for declaration

The reason for using weak is that there is a strong pointer pointing to him

UIView control: All the UI elements on the screen are called controls.

Attribute: Size, position, background color

Common attributes are extracted to UIView.

Every control is a container. Generally, UIVIew is used as a container.
The Controller is invisible. Each controller has a UIVIew. Each View has a UIVIew. All the sub-controls managed in the property controller of the UIVIew are the sub-controls of the space. Common methods are as follows:
// Add a sub-control view-(void) addSubview :( UIVIew *) view;
// Remove yourself from the parent control-(void) removeFromSuperview;
// Find a corresponding control (generally sub-Control) based on a tag ID-(UIView *) viewWithTag :( NSInteger) tag;
Common attributes
// Position and size of the rectangle frame of the control in the parent control. The coordinate origin is @ property (nonatomic) CGRect frame in the upper left corner. label. frame = CGRectMake (0, 0,100,100); // modify the method 1self. label. frame = CGRectMake (200,100,100, 50); // modification method 2 // struct is value transfer, not address transfer CGRect frame = self. label. frame; frame. origin. x-= 100; frame. size. width + = 50; self. label. frame = frame;
// The position and size of the rectangle frame of the control. The coordinates are taken as the origin in the upper left corner of the box. The x and y values of bounds are generally 0 @ property (nonatomic) CGRect bounds;
// The position of the control's midpoint @ property (nonatomic) CGPoint center;
ViewDidLoad
/** 1. system Call 2. call the controller when the View is loaded. 3. control initialization, data initialization (lazy loading) */-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib .}
DidReceiveMemoryWarning
/** 1. system Call 2. when the Controller receives a memory warning call 3. remove unnecessary memory and time-consuming memory */-(void) didReceiveMemoryWarning {[super didreceivemorywarning]; // Dispose of any resources that can be recreated .}
Button

Button event

-(IBAction) clickRedButton {// change the text color self. label. textColor = [UIColor redColor]; // modify the text content self. label. text = @ "I am red"; // change the text background color self. label. backgroundColor = [UIColor greenColor]; // change the text alignstextalignmentcenter: Center, NSTextAlignmentRight: Right, NSTextAlignmentLeft: Left self. label. textAlignment = NSTextAlignmentCenter; // modify the text size self. label. font = [UIFont systemFontOfSize: 30.f];}

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.