你如何在 UIBarItem 中使用 setTitleTextAttributes:forState?

How do you use setTitleTextAttributes:forState in UIBarItem?(你如何在 UIBarItem 中使用 setTitleTextAttributes:forState?)
本文介绍了你如何在 UIBarItem 中使用 setTitleTextAttributes:forState?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOSUIBarItem中的setTitleTextAttributes:forState:如何使用?

你如何设置NSDictionary?无法使其工作,文档对此也不是很清楚.

How do you set the NSDictionary? Can't make it work and documentation isn't very clear about that.

来自文档:

setTitleTextAttributes:forState:

为给定的控件状态设置标题的文本属性:

- (void)setTitleTextAttributes:(NSDictionary *)attributes 
                      forState:(UIControlState)state

参数:

attributes:包含文本属性键值对的字典.您可以使用 NSString UIKit Additions Reference 中列出的键指定字体、文本颜色、文本阴影颜色和文本阴影偏移量.

attributes: A dictionary containing key-value pairs for text attributes. You can specify the font, text color, text shadow color, and text shadow offset using the keys listed in NSString UIKit Additions Reference.

state:要为其设置标题文本属性的控件状态.

state: The control state for which you want to set the text attributes for the title.

推荐答案

示例代码:

[[UIBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:220.0/255.0 green:104.0/255.0 blue:1.0/255.0 alpha:1.0], UITextAttributeTextColor, 
[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0], UITextAttributeTextShadowColor, 
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, 
[UIFont fontWithName:@"AmericanTypewriter" size:0.0], UITextAttributeFont, nil] 
forState:UIControlStateNormal];

这篇关于你如何在 UIBarItem 中使用 setTitleTextAttributes:forState?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
Dropbox Files.download does not start when number of files in folder is gt; 1000(当文件夹中的文件数为1000时,Dropbox Files.Download不会启动)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)