我正在使用以下代码调整我的appplication中的按钮
+(void) processButton:(UIButton*) button buttonType:(NSString*)buttonType {
ENDebug(@"Process button %@" ,[button restorationIdentifier]);
[button setTranslatesAutoresizingMaskIntoConstraints:true];
CGRect rect = [button frame];
float startx = rect.origin.x;
float midx = startx +rect.size.width/2;
float starty = rect.origin.y;
float midy = starty +rect.size.height/2;
if ([buttonType isEqualToString:BUTTON_IPAD_SMALL]||[buttonType isEqualToString:BUTTON_IPHONE_SMALL]) {
rect.size.width = BUTTON_WIDTH_SMALL;
rect.size.height = BUTTON_HEIGHT_SMALL;
} else {
rect.size.width = BUTTON_WIDTH_LARGE;
rect.size.height = BUTTON_HEIGHT_LARGE;
}
rect.origin.x = midx - rect.size.width/2;
rect.origin.y = midy-rect.size.height/2;
button.titleLabel.font = GillSansBold(BUTTON_TITLE_SIZE);
[button setFrame:rect];
}
使用此功能我可以调整代码大小..但是无法增加按钮的按键大小。看起来只有视图已经扩展而按钮无法完全点击。
答案 0 :(得分:0)
检查按钮的边缘插入物。插图是绘图矩形周围的边距。或者你不能尝试:
button.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
设置按钮的框架后。