iOS Development-uibutton Detailed

Source: Internet
Author: User

UIButton is the most basic of a control, but sometimes use a lot about UIButton text position, font size, font color

1. Set the UIButton font size, paying particular attention to not using direct call SetFont:

[Self.playButton.titleLabel Setfont:[uifont systemfontofsize:14];

2.UIButton default background is white, if the text default color is white, is not visible text, set the title color:

   [Self.playbutton Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal];

3. After setting the color, it is likely that the title can not be displayed, check whether it is set by Titlelabel, should be directly set:

    [Self.playbutton settitle:@ "Flyelephant" forstate:uicontrolstatenormal];

4. Set the text center, the most easily through the title set nstextalignment, the results found unsatisfactory, this time can be through contenthorizontalalignment Settings:

    Self.playbutton.contenthorizontalalignment= Uicontrolcontenthorizontalalignmentleft;

The vertical direction is set in the same direction as the horizontal:

  Self.playbutton.contentverticalalignment=uicontrolcontentverticalalignmentbottom;

5. Setting left may be found too residing left, can be set by setcontentedgeinsets:

[Self.playbutton setcontentedgeinsets:uiedgeinsetsmake (0, 10, 0, 0)];

 

Basically this is the most error-prone place, remember to be careful ~

iOS Development-uibutton Detailed

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.