是否可以在iOS 7的tintColor颜色的UIActionSheet中使用按钮?我的意思是如果我的应用程序是品牌tintColor,例如红色,我不想在行动表中使用蓝色按钮.与UIAlertView相同.
解决方法
我想强调这违反了Apple的规则,但这有效:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
[actionSheet.subviews enumerateObjectsUsingBlock:^(UIView *subview,NSUInteger idx,BOOL *stop) {
if ([subview isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)subview;
button.titleLabel.textColor = [UIColor greenColor];
Nsstring *buttonText = button.titleLabel.text;
if ([buttonText isEqualToString:NSLocalizedString(@"Cancel",nil)]) {
[button setTitleColor:[UIColor greenColor] forState:UIControlStatenormal];
}
}
}];
}
(符合UIActionSheetDelegate)
尚未尝试过UIAlertView.