iphone - uiactionsheet 的背景颜色

标签 iphone objective-c

我尝试更改操作表的背景颜色,我只是使用以下方法:

[actionSheet setBackgroundColor:[UIColor colorWithRed:30 绿色:30 蓝色:30 alpha:0.5]];

我把它放在 willPresentActionSheet 中。但背景颜色没有改变,为什么?

最佳答案

  • 添加 QuartzCore.framework
  • 为您的操作表设置委托(delegate)
  • 设置操作表样式:UIActionSheetStyleBlackTranslucent
  • 重写方法 willPresentActionSheet
#import "QuartzCore/QuartzCore.h"
...

yourActionSheet.delegate = self;
yourActionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
...

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
    [[actionSheet layer] setBackgroundColor:[UIColor redColor].CGColor];
}

关于iphone - uiactionsheet 的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3426272/

相关文章:

iphone - iPhone SDK 中的文本域输入验证

iphone - 在 iPhone WebApp 文本框中更改 "return key"

ios - 在 iOS 9 中,为什么 SFSafariViewController 被推送而不是模态呈现?

iphone - 在 iOS7 上注入(inject)系统范围的触摸事件

objective-c - 在 plist 中更新和保存数据

ios - 使用 webView ios 显示下载的 PDF 文件

iphone - 使用 Core Data 获取按日期时间排序的第一个不同实体

ios - 中心 didReceiveNotificationResponse 没有被调用

iphone - 一次 UIAlert?

ios - 在Splitviewcontroller中从左到右更改Masterview的位置