我一直在寻找互联网,尝试不同的事情,但似乎无法改变我的行动表上的按钮标题颜色。如何设置UIActionSheet按钮颜色
以下是操作表代码。
- (void)showActionSheet
{
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"Select Country"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
for (NSString *listCountry in resultSet) [actionSheet addButtonWithTitle:listCountry];
[actionSheet showInView:[self.view window]];
}
我试过这个委托,但它不起作用。
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
for (UIView *subview in actionSheet.subviews) {
if ([subview isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)subview;
button.titleLabel.textColor = [UIColor greenColor];
}
}
}
检查出这个http://stackoverflow.com/a/4248450/1865424 – Shivaay
[UIActionSheet按钮的颜色]的可能重复(http://stackoverflow.com/questions/4248400/uiactionsheet-buttons-color ) – Michael
我认为你的代码似乎是一个完美的。放置brekpoint willPresentActionSheet是否被调用 –