Ios7 如何在iOS 7中更改UIActionSheet的颜色?

Ios7 如何在iOS 7中更改UIActionSheet的颜色?,ios7,customization,xcode5,Ios7,Customization,Xcode5,我希望我能在iOS 7中使用自定义颜色来显示操作表。几天以来我一直在寻找合适的答案。 谢谢你的帮助 我正在使用UIActionsheet在其中显示PickerView UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by t

我希望我能在iOS 7中使用自定义颜色来显示操作表。几天以来我一直在寻找合适的答案。 谢谢你的帮助

我正在使用UIActionsheet在其中显示PickerView

 UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy.
 If you need to present a sheet with more customization than provided by the
 UIActionSheet API, you can create your own.
根据苹果公司的文件

所以你必须使用一些自定义类


展示这一点。

我想强调这违反了苹果的规则,但这是可行的:

- (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

我创建了一个类,该类扩展了UIActionSheet功能,能够为操作表按钮设置颜色、字体、文本颜色和图像。它适用于iOs6和iOs7,也适用于iPhone和iPad应用程序。
它不使用隐藏的API,因此对Appstore来说是安全的。享受。

谢谢,伙计,威尔将下载并测试itAny idea为什么在纵向模式下颜色显示正确,但如果在横向模式下启动UIActionView,我只能看到颜色为“取消”的按钮,而其他按钮仅为黑色。也许UIActionSheet会在另一个视图中包装顶部按钮?因此,您需要递归地运行。你真的不想尝试做这种事。它很可能会在未来的iOS版本中崩溃,因为你并不打算这么做。完成审查过程可能也很棘手。