nsp*_*vlo 2 objective-c uibutton ios
当我尝试对齐uibutton textlabel时出现问题.在ios6上,它位于中心位置,但在ios7上它大约低了4个像素.
按钮类
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
[self setBackgroundImage:[UIImage imageNamed:@"circle"] forState:UIControlStateNormal];
[self.titleLabel setFont:[UIFont seBoldUserFontOfSize:13.0]];
_numberLabel = [[IBMSmallDescriptionTextLabel alloc] initWithFrame:CGRectMake(5.5, 0, 18, 18)];
[self addSubview:_numberLabel];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
在自定义标题中:
- (void)createButtons
{
for (int i = 0; i <= 5; i++)
{
IBMStageButton *button = [[IBMStageButton alloc] initWithFrame:CGRectMake(18.0 + (60.0 * i), 1.0, 18.0, 18.0)];
[button.numberLabel setText:[NSString stringWithFormat:@"%d", i+1]];
[self addSubview:button]; // self frame W320 H23
}
}
Run Code Online (Sandbox Code Playgroud)
我有这个.我用:
if (iOS_7_or_later) {
[button setTitleEdgeInsets:UIEdgeInsetsMake(2, 0, 0, 0)];
}
Run Code Online (Sandbox Code Playgroud)
iOS_7_or_later只是我使用的一个宏:
#define iOS_7_or_later SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3062 次 |
| 最近记录: |