UIButton SetImage and Settitle, the default image and title alignment is centered,
Because the title length is not fixed,
So if you want a couple of buttons that have an image with the title vertically aligned,
No matter how you adjust the imageedgeinsets and titleedgeinsets, it is possible to cause the front picture to be untidy,
So, just take a left to align!! Simplified processing!!
Remember, this setting:
Btn.contenthorizontalalignment =uicontrolcontenthorizontalalignmentleft;
Btn.contentverticalalignment = Uicontrolcontentverticalalignmentcenter;
UIButton more Alignment
typedef ns_enum (Nsinteger, uicontrolcontentverticalalignment) {
Uicontrolcontentverticalalignmentcenter = 0,//vertical, center aligned
Uicontrolcontentverticalalignmenttop = 1,//vertical, aligned
Uicontrolcontentverticalalignmentbottom = 2,//vertical, bottom-aligned
Uicontrolcontentverticalalignmentfill = 3,//Vertical, padding
};
typedef ns_enum (Nsinteger, uicontrolcontenthorizontalalignment) {
Uicontrolcontenthorizontalalignmentcenter = 0,//left/right, center aligned
Uicontrolcontenthorizontalalignmentleft = 1,//left-aligned
Uicontrolcontenthorizontalalignmentright = 2,//left, right
Uicontrolcontenthorizontalalignmentfill = 3,//left/right, padding
};
Align picture and text in UIButton to the left