UIActionSheet(或UIAlertView)的tintColor(iOS 7)

前端之家收集整理的这篇文章主要介绍了UIActionSheet(或UIAlertView)的tintColor(iOS 7)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否可以在iOS 7的tintColor颜色的UIActionSheet中使用按钮?我的意思是如果我的应用程序是品牌tintColor,例如红色,我不想在行动表中使用蓝色按钮.与UIAlertView相同.

解决方法

我想强调这违反了Apple的规则,但这有效:
  1. - (void)willPresentActionSheet:(UIActionSheet *)actionSheet
  2. {
  3. [actionSheet.subviews enumerateObjectsUsingBlock:^(UIView *subview,NSUInteger idx,BOOL *stop) {
  4. if ([subview isKindOfClass:[UIButton class]]) {
  5. UIButton *button = (UIButton *)subview;
  6. button.titleLabel.textColor = [UIColor greenColor];
  7. NSString *buttonText = button.titleLabel.text;
  8. if ([buttonText isEqualToString:NSLocalizedString(@"Cancel",nil)]) {
  9. [button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
  10. }
  11. }
  12. }];
  13. }

(符合UIActionSheetDelegate)

尚未尝试过UIAlertView.

猜你在找的iOS相关文章