I'm struggeling with an issuse for quite a while now. Since I don't really find a solution, I hope somebody here will be able to help me.
I have a UIActionSheet that I want to have a different background color. With
[[myAlert layer] setBackgroundColor:[UIColor redColor].CGColor];
I am able to change most of the alert's color. This is how it looks like:
This is how I initialize the UIActionSheet:
UIActionSheet *styleAlert = [[UIActionSheet alloc] initWithTitle:AMLocalizedString(@"SELECT_PICTURE_TITLE", @"Überschrift des Actionsheets")
delegate:self
cancelButtonTitle:AMLocalizedString(@"CANCEL_BUTTON_TITLE", @"Abbrechen butten")
destructiveButtonTitle:nil
otherButtonTitles:AMLocalizedString(@"TAKE_PICTURE_BUTTON_TITLE", @"Bild aufnehmen button"),
AMLocalizedString(@"CAMERA_ROLL_BUTTON_TITLE", @"Aus Bibliothek auswählen"), nil];
// use the same style as the nav bar
[styleAlert showInView:self.parentViewController.tabBarController.view];
//[styleAlert showInView:[self.navigationController view] ];
[styleAlert release];
and
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
actionSheet.layer.backgroundColor = GLOBAL_TINT_COLOR.CGColor;
}
I could not figure out how to set the border with the same color. Any ideas?
Thanks in advance!
You can't redraw the border in a different color, so just remove the border and add your own:
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet {
UIView *contentView = actionSheet.superview;
UIView *popoverView = contentView.superview;
UIView *chromeView;
for (UIView *v in [popoverView subviews]) {
if (v.subviews.count == 3) {
chromeView = v;
break;
}
}
for (UIView *backgroundComponentView in [chromeView subviews]) {
backgroundComponentView.hidden = YES;
CGRect componentFrame = backgroundComponentView.frame; // add your view with this frame
}
}
Note that this won't work in *will*PresentActionSheet since actionSheet
doesn't have a superview
set at that point.