修改UIBarButtonItem字体大小、颜色等相关属性
在ios中如果想修改UIBarButtonItem里面的内容有很多种方法,常见的就是自定义contentView 但是有时候因为懒不想自定义只想在原来的文字上进行修改 如果只是修改UIBarButtonItem的文字颜色挺简单,一行代码搞定:
[self.navigationItem.rightBarButtonItem setTintColor:[UIColor whiteColor]];
但如果想修改文字的尺寸 阴影等其他复杂效果是就找不到直接的修改方法了 但可以通过下面的方法做到:
[self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:],NSFontAttributeName, nil] forState:UIControlStateNormal];
其中需要注意的是键值对的设置: [属性值1,属性名1,属性值2,属性名2,....nil]
[UIFont boldSystemFontOfSize:],NSFontAttributeName, nil]
以上方法就可以设置更多的显示效果了
PS ios修改文字相关属性键值对中的key名:
// Predefined character attributes for text. If the key is not in the dictionary, then use the default values as described below.
UIKIT_EXTERN NSString * const NSFontAttributeName NS_AVAILABLE(10_0, 6_0); // UIFont, default Helvetica(Neue) 12
UIKIT_EXTERN NSString * const NSParagraphStyleAttributeName NS_AVAILABLE(10_0, 6_0); // NSParagraphStyle, default defaultParagraphStyle
UIKIT_EXTERN NSString * const NSForegroundColorAttributeName NS_AVAILABLE(10_0, 6_0); // UIColor, default blackColor
UIKIT_EXTERN NSString * const NSBackgroundColorAttributeName NS_AVAILABLE(10_0, 6_0); // UIColor, default nil: no background
UIKIT_EXTERN NSString * const NSLigatureAttributeName NS_AVAILABLE(10_0, 6_0); // NSNumber containing integer, default 1: default ligatures, 0: no ligatures
UIKIT_EXTERN NSString * const NSKernAttributeName NS_AVAILABLE(10_0, 6_0); // NSNumber containing floating point value, in points; amount to modify default kerning. 0 means kerning is disabled.
UIKIT_EXTERN NSString * const NSStrikethroughStyleAttributeName NS_AVAILABLE(10_0, 6_0); // NSNumber containing integer, default 0: no strikethrough
UIKIT_EXTERN NSString * const NSUnderlineStyleAttributeName NS_AVAILABLE(10_0, 6_0); // NSNumber containing integer, default 0: no underline
UIKIT_EXTERN NSString * const NSStrokeColorAttributeName NS_AVAILABLE(10_0, 6_0); // UIColor, default nil: same as foreground color
UIKIT_EXTERN NSString * const NSStrokeWidthAttributeName NS_AVAILABLE(10_0, 6_0); // NSNumber containing floating point value, in percent of font point size, default 0: no stroke; positive for stroke alone, negative for stroke and fill (a typical value for outlined text would be 3.0)
UIKIT_EXTERN NSString * const NSShadowAttributeName NS_AVAILABLE(10_0, 6_0); // NSShadow, default nil: no shadow
UIKIT_EXTERN NSString *const NSTextEffectAttributeName NS_AVAILABLE(10_10, 7_0); // NSString, default nil: no text effect UIKIT_EXTERN NSString * const NSAttachmentAttributeName NS_AVAILABLE(10_0, 7_0); // NSTextAttachment, default nil
UIKIT_EXTERN NSString * const NSLinkAttributeName NS_AVAILABLE(10_0, 7_0); // NSURL (preferred) or NSString
UIKIT_EXTERN NSString * const NSBaselineOffsetAttributeName NS_AVAILABLE(10_0, 7_0); // NSNumber containing floating point value, in points; offset from baseline, default 0
UIKIT_EXTERN NSString * const NSUnderlineColorAttributeName NS_AVAILABLE(10_0, 7_0); // UIColor, default nil: same as foreground color
UIKIT_EXTERN NSString * const NSStrikethroughColorAttributeName NS_AVAILABLE(10_0, 7_0); // UIColor, default nil: same as foreground color
UIKIT_EXTERN NSString * const NSObliquenessAttributeName NS_AVAILABLE(10_0, 7_0); // NSNumber containing floating point value; skew to be applied to glyphs, default 0: no skew
UIKIT_EXTERN NSString * const NSExpansionAttributeName NS_AVAILABLE(10_0, 7_0); // NSNumber containing floating point value; log of expansion factor to be applied to glyphs, default 0: no expansion UIKIT_EXTERN NSString * const NSWritingDirectionAttributeName NS_AVAILABLE(10_6, 7_0); // NSArray of NSNumbers representing the nested levels of writing direction overrides as defined by Unicode LRE, RLE, LRO, and RLO characters. The control characters can be obtained by masking NSWritingDirection and NSTextWritingDirection values. LRE: NSWritingDirectionLeftToRight|NSWritingDirectionEmbedding, RLE: NSWritingDirectionRightToLeft|NSWritingDirectionEmbedding, LRO: NSWritingDirectionLeftToRight|NSWritingDirectionOverride, RLO: NSWritingDirectionRightToLeft|NSWritingDirectionOverride, UIKIT_EXTERN NSString * const NSVerticalGlyphFormAttributeName NS_AVAILABLE(10_7, 6_0); // An NSNumber containing an integer value. 0 means horizontal text. 1 indicates vertical text. If not specified, it could follow higher-level vertical orientation settings. Currently on iOS, it's always horizontal. The behavior for any other value is undefined.
修改UIBarButtonItem字体大小、颜色等相关属性的更多相关文章
- 修改Xshell字体大小和颜色
博客专区 > XManager的博客 > 博客详情 修改Xshell字体大小和颜色 XManager 发表于7个月前 分享到: 一键分享 QQ空间 微信 腾讯微博 新浪微博 QQ好友 有道 ...
- 设置全局导航栏颜色,标题大小和UIBarButtonItem字体大小
设置全局导航栏颜色,标题大小和UIBarButtonItem字体大小 在appdelegate里面设置 swift: UINavigationBar.appearance().barTintColor ...
- 利用NSMutableAttributedString实现label上字体大小颜色行间距的改变
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.si ...
- 【xshell属性设置】如何修改xshell字体大小
1.周末在家,想搞一下学习,于是远程公司的电脑(我的移动硬盘在公司,里面有虚拟机及测试环境) 发现xshell界面字体太小,不方便看,于是研究了一下如何来设置xshell 的字体大小 2.点击左上角的 ...
- 1.0、修改MyEclipse字体大小及颜色
windows-->prefereces->General-->Appearance-->Colors and Fonts,在右边找到要修改的字体或背景,双击点Edit修改即可 ...
- 修改MyEclipse字体大小及颜色
windows-->prefereces->General-->Appearance-->Colors and Fonts,在右边找到要修改的字体或背景,双击点Edit修改即可 ...
- Eclipse(MyEclipse)使用技巧——修改注释字体大小
Eclipse在安装完成后,注释的字体大小远远小于代码的大小,按照网上查的相关信息 窗口——首选项——常规——外观——颜色和字体——基本——文本字体——编辑 Window -->Preferen ...
- 在iOS7中修改状态栏字体的颜色-b
状态栏的字体为黑色: UIStatusBarStyleDefault 状态栏的字体为白色: UIStatusBarStyleLightContent 一.在 info.plist 中,将 View ...
- 在iOS7中修改状态栏字体的颜色
http://www.2cto.com/kf/201408/324442.html 默认状态栏的字体为黑色:UIStatusBarStyleDefault 状态栏的字体为白色:UIStatusBarS ...
随机推荐
- 8、四大组件之三-ContentProvider
课程目标: 理解ContentProvider的作用及好处 认清ContentProvider与数据存储的关系 掌握ContentProvider对外提供的数据模型形式 能够编写ContentReso ...
- Print the numbers between 30 to 3000.
Microsoft Interview Question Developer Program Engineers 看到一个题目比较有意思: Print the numbers between 30 t ...
- ThoughtWorks(中国)程序员读书雷达 —— 书籍下载整理
ThoughtWorks(中国)程序员读书雷达 http://agiledon.github.io/blog/2013/04/17/thoughtworks-developer-reading-rad ...
- HDU-4696 Answers 纯YY
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4696 题意:给一个图,每个点的出度为1,每个点的权值为1或者2.给n个询问,问是否能找到一条路径的权值 ...
- 28个MongoDB NoSQL数据库的面试问答
MongoDB是目前最好的面向文档的免费开源NoSQL数据库.如果你正准备参加MongoDB NoSQL数据库的技术面试,你最好看看下面的MongoDB NoSQL面试问答.这些MongoDB NoS ...
- Java HashMap实例源码分析
引言 HashMap在键值对存储中被经常使用,那么它到底是如何实现键值存储的呢? 一 Entry Entry是Map接口中的一个内部接口,它是实现键值对存储关键.在HashMap中,有Entry的实现 ...
- Java注解处理器使用详解
在这篇文章中,我将阐述怎样写一个注解处理器(Annotation Processor).在这篇教程中,首先,我将向您解释什么是注解器,你可以利用这个强大的工具做什么以及不能做什么:然后,我将一步一步实 ...
- [Objective-c 基础 - 2.2] OC弱语法、类方法
A.OC弱语法 1.在运行的时候才会检查方法的声明和实现 2.没有声明只有实现的方法也能正常运行,只要在调用之前定义即可 3.类的声明必须存在,否则会出现运行时错误 B.类方法 1.是类名调用的方 ...
- IEnumerable和IEnumerator 详解
初学C#的时候,老是被IEnumerable.IEnumerator.ICollection等这样的接口弄的糊里糊涂,我觉得有必要切底的弄清楚IEnumerable和IEnumerator的本质. 下 ...
- squid3.0 隐藏 hearder 设置
原文地址: http://www.wenzizone.cn/?p=311 squid2.6可以使用header_access来控制显示与隐藏http的header信息,但是在squid3.0版本中这个 ...