iOS 相册取消按钮颜色及尺寸修改

修改返回按钮和取消按钮的颜色和尺寸
//配置返回按钮的颜色和大小
- (void)configBarButtonItemAppearance {
    UIBarButtonItem *barItem;
    if (iOS9Later) {
        barItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TOPCONTROLLER class]]];
    } else {
        barItem = [UIBarButtonItem appearanceWhenContainedIn:[TOPCONTROLLER class], nil];
    }
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = GTColor_A2;
    textAttrs[NSFontAttributeName] = GTFont_T2;
    [barItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
}

其中

//获取当前顶部视图
#define TOPCONTROLLER ([UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController ? [UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController : [UIApplication sharedApplication].keyWindow.rootViewController)

#define GTColor_A2 HEXRGB(0x666666)

#define GTFont_T2 [UIFont systemFontOfSize:GTWordSize_T2]
  • barItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TOPCONTROLLER class]]];这种方法只改变当前页面,
  • barItem = [UIBarButtonItem appearance];这种方式改变全局

改变title颜色和navigation的背景色
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.navigationBar.barTintColor = [UIColor whiteColor];
    imagePicker.delegate = self;
    TOPCONTROLLER.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    [imagePicker.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:GTColor_A1}];
    if ([imagePicker.navigationBar respondsToSelector:@selector(setBarTintColor:)]) {
        
        [imagePicker.navigationBar setTranslucent:YES];
        [imagePicker.navigationBar setTintColor:GTColor_A2];
        
    }

你可能感兴趣的:(iOS 相册取消按钮颜色及尺寸修改)