我知道如何設置IB對齊按鈕的垂直對齊方式;見here。但我不能這樣做編程...這是我試過的事情之一:如何以編程方式設置UIButton的垂直對齊 - iOS
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(我不想要默認的外觀和感覺)。
+1用於回答我的問題100%。但是我不會告訴你,因爲你沒有讀懂我的想法......對不起,我應該更好地指出這個問題。我也想保留自定義類型。我會修改我的問題以反映這一點。如果沒有更好的答案出現,我會給你打勾。乾杯。 – 2011-12-15 01:36:32
有趣的是,當你(錯誤地)通過訪問titleLabel(而不是發送setTitleColor消息)來改變字體顏色時,這將停止工作 – 2011-12-15 01:39:19