iOS 全局设置属性

2018-05-29  本文已影响6人  烟雨痕

全局设置导航栏 隐藏返回Btn Item属性

#pragma mark -- 全局配置导航栏
- (void)configureAllNavigation {
    //全局设置导航栏字体大小不随字体系数multiplying变化
        CGFloat fontValue = multiplying >= 1.0 ? 17.0 / multiplying  : 17.0 * multiplying;

    //PingFang_S_FONT_ :字体设置宏
    NSDictionary *barDic = @{NSForegroundColorAttributeName: [UIColor whiteColor],           NSFontAttributeName: PingFang_S_FONT_(fontValue)};
    [[UINavigationBar appearance] setTitleTextAttributes:barDic];

    //全局设置背景图片   [UnifyUIHandler navBarBackgroundImage] 自己设置的UIImage
    [[UINavigationBar appearance] setBackgroundImage:[UnifyUIHandler navBarBackgroundImage] forBarMetrics:UIBarMetricsDefault];

    //全局设置UIBarButtonItem属性
    NSDictionary *itemDic = @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName: PingFang_R_FONT_(fontValue)};
    [[UIBarButtonItem appearance] setTitleTextAttributes:itemDic forState:UIControlStateNormal];

    //全局隐藏返回按钮
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, - 60) forBarMetrics:UIBarMetricsDefault];

    //全局设置MBProgressHUD的菊花框为黑色
    [UIActivityIndicatorView appearanceWhenContainedIn:[MBProgressHUD class], nil].color = [UIColor blackColor];

   //全局设置UISearchBar “取消”按钮字体颜色为黑色
   [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateNormal];
}
上一篇 下一篇

猜你喜欢

热点阅读