UIActionSheet没有显示半透明

时间:2010-12-29 19:13:02

标签: ios4 coding-style subview uiactionsheet

我想从rootViewController中显示一个非常简单的UIActionsheet:

- (void)viewWillAppear:(BOOL)animated {
  asButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showActionSheet:)];
}

-(IBAction) showActionSheet:(id)sender {

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil 
                                             otherButtonTitles:@"Add current location", @"Center map", nil];

    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

    [actionSheet showFromBarButtonItem:asButton animated:YES];

    [actionSheet release];
}

然而,出乎意料的是,它显示为不透明...... 万一重要:工具栏直接在appDelegate的窗口上创建为子视图(并且是半透明的):

CGRect toolbarFrame = CGRectMake(toolbarxOffset, toolbaryOffset, toolbarWidth,
                                 toolbarHeight);

self.myToolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame];
[self.myToolbar setBarStyle:UIBarStyleBlack];
[self.myToolbar setTranslucent:YES];
[window addSubview:self.myToolbar];

有人对此有解释吗?

1 个答案:

答案 0 :(得分:1)

在寻找不相关的东西时,我发现了这个:

iPhone development: How to create colored or translucent background for UIActionSheet?

也许这可以帮助...

相关问题