【发布时间】:2012-01-20 04:41:57
【问题描述】:
我知道如何使用 IB 设置按钮的垂直对齐方式;见here。但我不能以编程方式做到这一点......这是我尝试过的事情之一:
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 110, 130)];
[button setTitle:@"Align" forState:UIControlStateNormal];
button.backgroundColor = [UIColor whiteColor];
button.titleLabel.textColor = [UIColor grayColor];
[button setContentVerticalAlignment:UIControlContentVerticalAlignmentBottom];
[self.view addSubview:button];
[button release];
我也尝试过插入...
但对齐方式不会改变。
请注意,我想保留按钮的 CustomStyle(我不想要默认外观)。
【问题讨论】:
标签: ios cocoa-touch uibutton