- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
iOS
中UIBarItem
中的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/
所以我有 vc A 和 vc B。当我执行从 A 到 B 的推送转场时,会自动创建一个后退按钮。这很好,但我想使用 SetTitleTextAttributes 将此按钮的文本颜色更改为黑色。 通过阅
我正在尝试使用此代码在所有 View 中使用下划线setTextAttribute [[UINavigationBar appearance] setTitleTextAttributes:@{NS
我正在尝试自定义我的 UITabBarController。我将它嵌入到我的 UIViewController 中,我还为此 UITabBarController 创建了一个类。 override f
所以我尝试更改我的 UISegmentedControl 标题的文本属性,但它不起作用,没有任何变化。我还应用了自定义背景和分隔线,它可以正常工作,但不是这个。 NSDictionary *norma
iOS中UIBarItem中的setTitleTextAttributes:forState:如何使用? 你如何设置NSDictionary?无法使其工作,文档对此也不是很清楚。 来自文档: setT
我需要强制 iOS 8.4 及更高版本应用程序中的后退按钮文本始终为小写。 我已经使用AppDelegate来设置一些自定义外观。例如: UIBarButtonItem.appearance().se
iOS 10.3 在 UISegmentedControl 的 setTitleTextAttributes 方法上崩溃。 问题: 崩溃的原因是什么? 解决方案是什么? 注意:已将此问题报告给苹果,但
我花了一整天的时间尝试更改 UIBarButtonItem 的颜色,现在我认为这是一个 iOS 11 错误,除非有人能告诉我这是设计使然。 我可以使用这段代码改变文本的颜色 [self.refresh
我有一个部署目标为 iOS 9.3 的应用。 我刚刚升级到 Xcode 9.0.1,并且在所有模拟器设备和我自己的运行 iOS11 的 iPhone7 设备上都注意到了这个问题。该问题不会影响运行 <
我们的设计师要求我为禁用的 UIBarButtonItems 的文本使用特定颜色。我用来实现这个的代码: NSDictionary* textAttributes = [NSDictionary di
我在 didFinishLaunchingWithOptions 中使用外观代理来设置整个项目的 UIBarButtonItem 标题字体,如下所示: UIBarButtonItem.appearan
在我的 AppDelegate 实现文件中,我使用这些代码行来设置 tabBarItems 的自定义字体和颜色: [[UITabBarItem appearance] setTitleTextAttr
我是一名优秀的程序员,十分优秀!