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