开发者

background color of uiactionsheet [duplicate]

This question already has answers here: iPhone development: How to create colored or translucent background for UIActionSheet? (6 answers) Closed 3 years ago.

I try to change the background color of my actionsheet, I just use the method:

[actionSheet setBackgroundCol开发者_如何学Pythonor:[UIColor colorWithRed:30 green:30 blue:30 alpha:0.5]];

and I put it in the willPresentActionSheet. But the background color don't change, why?


  • add QuartzCore.framework
  • set delegate for your actionsheet
  • set style for actionsheet: UIActionSheetStyleBlackTranslucent
  • override method willPresentActionSheet
#import "QuartzCore/QuartzCore.h"
...

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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜