Ios development Article 1-button, use of some attributes of the label button, ios-button

Source: Internet
Author: User

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.

 

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.