开发者

How can I make UIActionSheet translucent when shown from a tab bar?

I am using a very simple UIActionSheet. Here is the code below:

 UIActionSheet *editActionSheet = [[UIActionSheet alloc] initWithTitle:@"What do you like to do?" 
                                                             delegate:self 
                                                    cancelButtonTitle:@"Cancel" 
                                               destructiveButtonTitle:@"Delete All Tasks" 
                                                    otherButtonTitles:@"Arrange Task List", @"Mark All as Done", nil];

editActionSheet.actionSheetStyle = UIBarStyleBlackTranslucent;
[editActionSheet showFromTabBar:appDel.tabBarController.tabBar];
[editActionSheet release];

Although I set the action sheet style to translucent, it always appear开发者_运维百科 opaque. I don't know why?

Thank you,


What I did in an app I'm creating was use [editActionSheet showInView:appDel.tabBarController.superview]; instead of [editActionSheet showFromTabBar:appDel.tabBarController.tabBar];. Accomplishes the same thing for all intents and purposes, and is much easier to implement than your answer. Just another way.


When an action sheet is shown from a tab bar it will always take on the appearance of the tab bar. You can't make it translucent in this case. I haven't tried subclassing UIActionSheet and overriding any of the color or drawing properties but that might be worth a shot.

I'd recommend changing the title of your question to reflect the actual question (e.g. How can I make UIActionSheet translucent when shown from a tab bar?)


XJones, finally, I managed to get the translucent action sheet!.

First, I hide the tab bar, then I show the translucent action sheet and immediatley after that show the tab bar. The finally code would be like that:

appDel.tabBarController.tabBar.hidden = YES;
NSString *controlBar;
if ([[settingsDictionary objectForKey:@"Task Control Bar"] isEqualToString:@"Hidden"]) {
    controlBar = @"Show Task Control Bar";
} else {
    controlBar = @"Hide Task Control Bar";
}

UIActionSheet *editActionSheet = [[UIActionSheet alloc] initWithTitle:@"What do you like to do?" 
                                                             delegate:self 
                                                    cancelButtonTitle:@"Cancel" 
                                               destructiveButtonTitle:@"Delete All Tasks" 
                                                    otherButtonTitles:@"Arrange Task List", @"Mark All as Done", controlBar, nil];

editActionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[editActionSheet showInView:self.tableView]; 
appDel.tabBarController.tabBar.hidden = NO;
[editActionSheet release];

You know what, I know now why Apple wanted this action sheet to be opaque. The translucent action sheet cancel button conflicts a little bit with the selected bar item (the blue one). It's not "so" noticed but I think an opaque one is a better solution.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜