设置导航栏与导航栏按钮的样式

设置导航栏与导航栏按钮的样式,第1张

概述设置导航栏与导航栏按钮样式

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

/** *  设置导航栏主题 */+ (voID)setupNavbartheme{    // 取出appearance对象    UINavigationbar *navbar = [UINavigationbar appearance];        // 设置背景    if (!iOS7) {        [navbar setBackgroundImage:[UIImage imageWithname:@"navigationbar_background"] forbarMetrics:UIbarMetricsDefault];        [UIApplication sharedApplication].statusbarStyle = UIStatusbarStyleBlackOpaque;    }        // 设置标题属性    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];    textAttrs[UITextAttributeTextcolor] = [UIcolor blackcolor];    //设置无阴影    textAttrs[UITextAttributeTextShadowOffset] = [NSValue valueWithUIOffset:UIOffsetZero];    textAttrs[UITextAttributeFont] = [UIFont boldSystemFontOfSize:19];    [navbar setTitleTextAttributes:textAttrs];}/** *  设置导航栏按钮主题 */+ (voID)setupbarbuttonItemtheme{    UIbarbuttonItem *item = [UIbarbuttonItem appearance];        // 设置背景    if (!iOS7) {        [item setBackgroundImage:[UIImage imageWithname:@"navigationbar_button_background"] forState:UIControlStatenormal barMetrics:UIbarMetricsDefault];        [item setBackgroundImage:[UIImage imageWithname:@"navigationbar_button_background_pushed"] forState:UIControlStateHighlighted barMetrics:UIbarMetricsDefault];        [item setBackgroundImage:[UIImage imageWithname:@"navigationbar_button_background_disable"] forState:UIControlStateDisabled barMetrics:UIbarMetricsDefault];    }        // 设置文字属性    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];    textAttrs[UITextAttributeTextcolor] = iOS7 ? [UIcolor orangecolor] : [UIcolor graycolor];    textAttrs[UITextAttributeTextShadowOffset] = [NSValue valueWithUIOffset:UIOffsetZero];    textAttrs[UITextAttributeFont] = [UIFont systemFontOfSize:iOS7 ? 14 : 12];    [item setTitleTextAttributes:textAttrs forState:UIControlStatenormal];    [item setTitleTextAttributes:textAttrs forState:UIControlStateHighlighted];            NSMutableDictionary *disableAttrs = [NSMutableDictionary dictionary];    disableAttrs[UITextAttributeTextcolor] = [UIcolor graycolor];    [item setTitleTextAttributes:disableAttrs forState:UIControlStateDisabled];}

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的设置导航栏与导航栏按钮的样式全部内容,希望文章能够帮你解决设置导航栏与导航栏按钮的样式所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1105831.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存