iOS 10导航栏常用属性设置

//设置整个项目的item状态

UIBarButtonItem *item = [UIBarButtonItemappearance];

//设置item普通状态

NSMutableDictionary *attrs = [NSMutableDictionarydictionary];

//设置字体及字体大小

例:attrs[NSFontAttributeName] = [UIFontsystemFontOfSize:17];

//设置字体颜色

例:attrs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];

//设置全局item的属性

例:[itemsetTitleTextAttributes:attrsforState:UIControlStateNormal];

//设置item不可用状态

NSMutableDictionary *disabledAttrs = [NSMutableDictionarydictionary];

//设置字体及字体大小

例:disabledAttrs[NSFontAttributeName] = [UIFontsystemFontOfSize:17];

//设置字体颜色

例:disabledAttrs[NSForegroundColorAttributeName] =[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];

//设置全局item的属性

例:[itemsetTitleTextAttributes:disabledAttrsforState:UIControlStateDisabled];

//隐藏返回按钮的返回两个字

例:[item setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];


//设置整个项目的UINavigationBar状态

UINavigationBar * bar = [UINavigationBarappearance];

//设置导航栏title的字体颜色、字体、字体大小

@property(nonatomic,copy)NSDictionary *titleTextAttributes;

例:[barsetTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColorblackColor],NSFontAttributeName:[UIFontsystemFontOfSize:17.0]}];

//设置导航栏系统按钮的颜色(默认是蓝色)

@property(nonatomic,retain)UIColor *tintColor

例:bar.tintColor = [UIColorblackColor];

//设置导航栏背景颜色

@property(nonatomic,retain)UIColor *barTintColor

例:bar.barTintColor = [UIColorblueColor];

//设置导航栏返回箭头图片 

// 必须要两个都设置,并且图片要设置成不渲染

@property(nonatomic,retain)UIImage *backIndicatorImage;

@property(nonatomic,retain)UIImage *backIndicatorTransitionMaskImage;

例:bar.backIndicatorTransitionMaskImage = [UIImageimageNamed:@"nav_back_B"];

例:bar.backIndicatorImage = [UIImageimageNamed:@"nav_back_B"];

//设置背景图片

// barMetrics需要设置成UIBarMetricsDefault

- (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics

//设置背景阴影图片

@property(nonatomic,retain)UIImage *shadowImage

//设置title文字垂直偏移量

- (void)setTitleVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值