作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
亲爱的,
我正在快速学习并且正在尝试为文本字段文本着色,现在的问题是颜色未应用于文本。请找到下一个代码:
let textStyle:[String:Any] = [
NSAttributedStringKey.strokeColor.rawValue: UIColor.black,
NSAttributedStringKey.foregroundColor.rawValue: UIColor.white,
NSAttributedStringKey.font.rawValue: UIFont (name: "Impact", size: 50)!,
NSAttributedStringKey.strokeWidth.rawValue: 3.5
]
谢谢
最佳答案
关键似乎是 .strokeWidth
...如果您想要描边和填充,描边宽度需要是一个负数值。
试一试:
let textStyle = [
NSAttributedStringKey.strokeColor: UIColor.black,
NSAttributedStringKey.foregroundColor: UIColor.white,
NSAttributedStringKey.font: UIFont(name: "Impact", size: 50)!,
NSAttributedStringKey.strokeWidth: -3.5
]
关于ios - swift 中文本字段的前景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47159728/
我是一名优秀的程序员,十分优秀!