gpt4 book ai didi

ios - 你如何使用 setTitleTextAttributes :forState in UIBarItem?

转载 作者:IT老高 更新时间:2023-10-28 11:48:31 24 4
gpt4 key购买 nike

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

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

来自文档:

setTitleTextAttributes:forState:

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

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

参数:

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

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

最佳答案

示例代码:

[[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];

关于ios - 你如何使用 setTitleTextAttributes :forState in UIBarItem?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7810563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com