给Iphone上的UiButton一个文本边距/填充 [英] giving a text margin / padding to the UiButton on the Iphone
问题描述
我有以下布局,我正在尝试向左右添加填充..
I have the following layout, and I'm trying to add a padding to the left and right..
控件是一些禁用的Uibutton。
the controls are some disabled Uibutton.
我的用于创建按钮的代码是:
My code for creating a button is this:
UIButton *buttonTime = [[UIButton alloc] initWithFrame:CGRectMake(90, 10, 50, 20)];
[buttonTime setBackgroundImage:[[UIImage imageNamed:@"bubble.png"] stretchableImageWithLeftCapWidth:9 topCapHeight:13] forState:UIControlStateDisabled];
[buttonTime setTitle:@"27 feb, 2011 11:10 PM" forState:UIControlStateDisabled];
[buttonTime setTitleColor:[UIColor blackColor] forState:UIControlStateDisabled];
buttonTime.titleLabel.font=[UIFont fontWithName:@"Helvetica" size:8.0];
buttonTime.titleLabel.lineBreakMode= UILineBreakModeWordWrap;
[buttonTime setEnabled:FALSE];
[scrollView addSubview:buttonTime];
[buttonTime release];
推荐答案
@property(nonatomic) UIEdgeInsets titleEdgeInsets;
使用此属性调整大小并重新定位按钮标题的有效绘图矩形。您可以为四个插入(顶部,左侧,底部,右侧)中的每一个指定不同的值。正值会缩小或缩小,使其更接近按钮的中心。负值会扩展或偏离该边缘。使用UIEdgeInsetsMake函数为此属性构造值。默认值为UIEdgeInsetsZero。
Use this property to resize and reposition the effective drawing rectangle for the button title. You can specify a different value for each of the four insets (top, left, bottom, right). A positive value shrinks, or insets, that edge—moving it closer to the center of the button. A negative value expands, or outsets, that edge. Use the UIEdgeInsetsMake function to construct a value for this property. The default value is UIEdgeInsetsZero.
这篇关于给Iphone上的UiButton一个文本边距/填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!