您的位置:首页 > 产品设计 > UI/UE

UIImagePickerController 状态栏颜色改变,自定义返回按钮

2015-07-01 17:22 531 查看
UIImagePickerController

在相册中选择图片时,推出图片选择的控制器时,状态会变为默认颜色。点取消返回后却没有变回去。

如果不想改变颜色,可以用下面的方法:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

{

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

}

UIImagePickerController是继承至UINavigationController。如果其他地方的UINavigationController用的UINavigationController的子类,并且自定义了返回按钮。在UIImagePickerController中的返回按钮不会改变,可以用下面的方法:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

{

_imageNavigationController = navigationController;

if (viewController.navigationItem.leftBarButtonItem == nil && [navigationController.viewControllers count] > 1) {

viewController.navigationItem.leftBarButtonItem =[self createBackButton:navigationController];

}

}

-(UIBarButtonItem*)createBackButton:(UINavigationController *)navigationController

{

UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStyleBordered target:self action:@selector(popViewController)];

return barButtonItem;

}

-(void)popViewController

{

[_imageNavigationController popViewControllerAnimated:YES];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: