button1.titleEdgeInsets=UIEdgeInsetsMake(0, 5, 0, 5);
where button1 is a UIButton. The default values is
The other thing to know is that the order for the values is TOP LEFT BOTTOM RIGHT.
This is opposite of the way we do it in CSS.
Also look out for the following other UIButton properties which accomplish similar padding tasks:
And there's that.
How can I also pad the inside of a UILabel?ReplyDelete
for a UILabel, i'd probably just make the frame smaller than the space, which will give the illusion of padding.ReplyDelete
e.g., if you had a 320x40 label (positioned at coordinates 0,100 for this example), created like this:
UILabel *label ==[[UILabel alloc]initWithFrame:CGRectMake(0,100,320,40)];
...and if you wanted 10px of padding on the left and right, you could change the way you create your uilabel to this...
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10,100,300,40)];
the width of 300px takes into account 10px of padding on the left and 10px of padding on the right.
i hope this helps!