iOS development--set UIButton

Source: Internet
Author: User

1. Set Title
1 @" Search [ Forstate:uicontrolstatenormal];
2. Set the font
1 // [btn setFont: [Uifont systemfontsize:14.0]];     // This can be used to set the size of the font, but may be removed 2 // should use 3 14.0];
3.Title Alignment

Sometimes we want UIButton's title to align to the left, we set

Btn.textLabel.textAlignment = Uitextalignmentleft

is not useful, we need to set

Btn.contenthorizontalalignment = Uicontrolcontenthorizonalignmentleft;

But the problem comes out again, when the text is pressed to make the border, we can set

Btn.contentedgeinsets = Uiedgeinsetsmake (0,00);

Keeps the text distance of 10 pixels from the border.

4. Set Title color

Set the color of the font on UIButton UIButton the color of the font, not with:

[Btn.titlelabel settextcolor:[uicolorblackcolor]];btn.titlelabel.textcolor=[uicolor RedColor];

Instead, use:

[Btn Settitlecolor:[uicolor Blackcolor]forstate:uicontrolstatenormal];

iOS development--set UIButton

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.