Self.siteButton.titleLabel.textAlignment = Nstextalignmentleft; That's not possible.
Self.sitebutton.contenthorizontalalignment=uicontrolcontenthorizontalalignmentleft;
[Self.sitebutton setTitle:model.siteStr Forstate:uicontrolstatenormal];
[Self.sitebutton settitlecolor:[uicolor colorwithred:78/255.0 green:189/255.0 blue:182.0/255.0 alpha:1.0] ForState: UIControlStateNormal];
Self.siteButton.titleLabel.font = [Uifont systemfontofsize:12.0f];
Reprinted from: http://blog.csdn.net/chengyingzhilian/article/details/8363855/
Btn.frame = CGRectMake (x, y, width, height);
[BTN Settitle: @ "search" forstate:uicontrolstatenormal];
Set the size of the self on the button
[Btn SetFont: [Uifont systemfontsize:14.0]]; This can be used to set the size of the font, but may be removed in the future SDK version of the change method
should use
Btn.titleLabel.font = [Uifont systemfontofsize:14.0];
[Btn sebackgroundcolor: [Uicolor Bluecolor]];
Finally joins the button to the specified view Superview
[Superview ADDSUBVIEW:BTN];
==========================================================
Tvnamelabel=[[uibutton Alloc]initwithframe:cgrectmake (5,5,200,40)];
This initializes the button, the text default color is white, all if the background is also white, can not see the text,
Btn.contenthorizontalalignment=uicontrolcontenthorizontalalignmentleft;//Set text position, now set to left, default is center
[btn settitle:@ "title" forstate:uicontrolstatenormal];//Add text
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,10, 0, 0);
Keeps the text distance of 10 pixels from the border.
=======================================================
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];