TextField 字母是透明的
TextField letters are transparent
你好,我写了一个学习用的小Meme生成器App iOS。发展。现在我有一个问题。我为我的文本字段设置
let memeTextAttributes:[String:Any] = [
NSAttributedStringKey.strokeColor.rawValue: UIColor.black,
NSAttributedStringKey.foregroundColor.rawValue: UIColor.white,
NSAttributedStringKey.font.rawValue: UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
NSAttributedStringKey.strokeWidth.rawValue: 4.0,
]
func setUPTextField (textField : UITextField){
textField.delegate = textViewDelegate
textField.defaultTextAttributes = memeTextAttributes
textField.textAlignment = .center
}
我的 memeTextAttributes 有问题。如果我不设置 属性 我的信件是不透明的。它应该看起来像图片中的那样。但是这封信不应该是透明的。它们应该是带有黑色边框的白色。
有人有什么想法吗?
谢谢!
您需要为笔划宽度使用负值,如下所述:
https://developer.apple.com/library/content/qa/qa1531/_index.html
NSAttributedStringKey.strokeWidth.rawValue: -4.0
你好,我写了一个学习用的小Meme生成器App iOS。发展。现在我有一个问题。我为我的文本字段设置
let memeTextAttributes:[String:Any] = [
NSAttributedStringKey.strokeColor.rawValue: UIColor.black,
NSAttributedStringKey.foregroundColor.rawValue: UIColor.white,
NSAttributedStringKey.font.rawValue: UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
NSAttributedStringKey.strokeWidth.rawValue: 4.0,
]
func setUPTextField (textField : UITextField){
textField.delegate = textViewDelegate
textField.defaultTextAttributes = memeTextAttributes
textField.textAlignment = .center
}
我的 memeTextAttributes 有问题。如果我不设置 属性 我的信件是不透明的。它应该看起来像图片中的那样。但是这封信不应该是透明的。它们应该是带有黑色边框的白色。
有人有什么想法吗?
谢谢!
您需要为笔划宽度使用负值,如下所述: https://developer.apple.com/library/content/qa/qa1531/_index.html
NSAttributedStringKey.strokeWidth.rawValue: -4.0