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];
}
在相册中选择图片时,推出图片选择的控制器时,状态会变为默认颜色。点取消返回后却没有变回去。
如果不想改变颜色,可以用下面的方法:
- (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];
}
相关文章推荐
- 如何运用UIControl自定义iOS中的控件
- UI控件
- MQTT的学习研究(六) MQTT moquette 的 Blocking API 订阅消息客户端使用
- MQTT的学习研究(五) MQTT moquette 的 Blocking API 发布消息服务端使用
- MQTT的学习研究(四)moquette-mqtt 的使用之mqtt Blocking API客户端订阅并接收主题信息
- MQTT的学习研究(三)moquette-mqtt 的使用之mqtt服务发布主题信息
- MQTT的学习研究(二)moquette-mqtt 的使用之mqtt broker的启动
- UI效果
- Android自动化测试(UiAutomator)简要介绍
- ArduinoYun教程之配置Arduino Yun环境
- [js开源组件开发]query组件,获取url参数和form表单json格式
- 解决ntp的错误 no server suitable for synchronization found
- convertView、viewholder requestlayout与adapter的刷新机制
- ArduinoYun教程之配置Arduino Yun环境
- Error:No suitable device found: no device found for connection "System eth0"
- Android5.1 SystemUI 启动流程
- mosquitto 使用时出现的一些问题及其解决办法
- UITextField详解
- Diesel watches are sometimes manufactured so well that even a specialist wants unique equipment
- [leetcode] Permutation Sequence