当从选项卡栏显示时,如何使 UIActionSheet 半透明?

发布于 2024-11-02 03:00:01 字数 744 浏览 0 评论 0原文

我正在使用一个非常简单的 UIActionSheet。代码如下:

 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];

虽然我将操作表样式设置为半透明,但它始终显示为不透明。我不知道为什么?

谢谢你,

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,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

傻比既视感 2024-11-09 03:00:02

XJones,我终于拿到了半透明的动作表!

首先,我隐藏选项卡栏,然后显示半透明操作表,然后立即显示选项卡栏。最终的代码将是这样的:

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];

你知道吗,我现在知道为什么苹果希望这个操作表是不透明的。半透明操作表取消按钮与选定的栏项目(蓝色项目)有点冲突。并没有“那么”注意到,但我认为不透明的解决方案是更好的解决方案。

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.

疑心病 2024-11-09 03:00:01

我在创建的应用程序中所做的是使用 [editActionSheet showInView:appDel.tabBarController.superview]; 而不是 [editActionSheet showFromTabBar:appDel.tabBarController.tabBar]; 。出于所有意图和目的完成相同的事情,并且比您的答案更容易实现。只是另一种方式。

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.

挖个坑埋了你 2024-11-09 03:00:01

当从选项卡栏显示操作表时,它将始终呈现选项卡栏的外观。在这种情况下你不能让它变得半透明。我还没有尝试子类化 UIActionSheet 并覆盖任何颜色或绘图属性,但这可能值得一试。

我建议更改问题的标题以反映实际问题(例如,当从选项卡栏显示时,如何使 UIActionSheet 半透明?)

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?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文