background color of uiactionsheet [duplicate]
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];
}
精彩评论