定义如下: UIActionSheet *styleAlert = [[UIActionSheet alloc]initWithTitle:@"Choose a UIBarStyle:"
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Default", @"BlackOpaque", @"BlackTranslucent", nil, nil]; // use thesame style as the nav bar styleAlert.actionSheetStyle =self.navigationController.navigationBar.barStyle; //styleAlert.actionSheetStyle =UIActionSheetStyleAutomatic; [styleAlertshowInView:self.view]; [styleAlertrelease];
在委托里的操作代码如下: - (void)actionSheet:(UIActionSheet *)modalViewclickedButtonAtIndex:(NSInteger)buttonIndex { // Changethe navigation bar style, also make the status bar match withit switch(buttonIndex) { case0: { [UIApplication sharedApplication].statusBarStyle =UIStatusBarStyleDefault; self.navigationController.navigationBar.barStyle =UIBarStyleDefault; break; } case1: { [UIApplication sharedApplication].statusBarStyle =UIStatusBarStyleBlackOpaque; self.navigationController.navigationBar.barStyle =UIBarStyleBlackOpaque; break; } case2: { [UIApplication sharedApplication].statusBarStyle =UIStatusBarStyleBlackTranslucent; self.navigationController.navigationBar.barStyle =UIBarStyleBlackTranslucent; break; } } }