Ios development Article 1-button, use of some attributes of the label button, ios-button
I am using pure code and prefer storyboard development;
First, let's talk about the button. Generally, the object that creates a button in ios understands that UIButton * button name = [UIButton alloc] init];
I like to use [[UIButton alloc] initWithFrame: CGRectMake (x, y, width, heimpaired)]; directly give the location
Set the background color of the button. backgroundColor = [UIColor cyanColor];
Of course, if you don't think the system color is desired, you can customize the color. Yo button name. backgroundColor = [UIColor colorWithRed :( 12/255) green :( 22/255) blue: (32/255) alpha: 1.0];
To add text to a button, use [button name setTitle: @ "Custom content" forState: UIcontrolStateNOrmal];
ForState: attributes can be selected as needed
For the button text color, you can use [button name setTitleColor: [UIColor blueColor] forState: UIcontrolStateNOrmal];
The button name. titleLabel. textAlignment = NSTextAlignmentCenter can be used to center the button text;
It is very easy to add a common one to the root view. Do not forget [self. view addSubview: button name];
The label control is easier to use than the button. The establishment method is similar to the button, that is, the UILabel * label name
The text color can be directly indicated by the label name. textColor = [UIColor blackColor];
Focus on the font size settings
Label. font = [UIFont fontWithName: @ "font name" size: 14]; The font name is Arial. Helvetica 14 indicates the font size adjusted as needed
You can use the label name. text = @ "Custom input" to display words in the label ";
Today, because of the time relationship, we will first share some information here. Many attributes of the button are readonly, so we need to use set for calling, instead of set for label. We can simply use point syntax for calling, textField is actually similar to label. If you are interested, try it.