NSForegroundAttributeName 不工作。文本填充呈现透明
NSForegroundAttributeName not working. Text fill renders transparent
我试图将此文本的填充设置为白色,但填充是透明的,当我更改 NSForegroundAttribureName 时,它没有任何效果,下面是我的代码。
let textAttributes = [
NSFontAttributeName : UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
NSStrokeWidthAttributeName : 3.0,
NSForegroundColorAttributeName : UIColor.whiteColor(),
NSStrokeColorAttributeName : UIColor.blackColor()
]
在viewDidLoad()中
textFieldTop.defaultTextAttributes = textAttributes
如何将字体填充为白色?
let textAttributes = [
NSFontAttributeName : UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
NSStrokeWidthAttributeName : -3.0,//Shpuld be in minus
NSForegroundColorAttributeName : UIColor.whiteColor(),
NSStrokeColorAttributeName : UIColor.blackColor()
]
Text becomes invisible when stroke is added
kCTStrokeWidthAttributeName。该属性被解释为字体点大小的百分比,控制文本绘制模式:正值影响仅使用笔画绘制;负值用于描边和填充。
我试图将此文本的填充设置为白色,但填充是透明的,当我更改 NSForegroundAttribureName 时,它没有任何效果,下面是我的代码。
let textAttributes = [
NSFontAttributeName : UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
NSStrokeWidthAttributeName : 3.0,
NSForegroundColorAttributeName : UIColor.whiteColor(),
NSStrokeColorAttributeName : UIColor.blackColor()
]
在viewDidLoad()中
textFieldTop.defaultTextAttributes = textAttributes
如何将字体填充为白色?
let textAttributes = [
NSFontAttributeName : UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
NSStrokeWidthAttributeName : -3.0,//Shpuld be in minus
NSForegroundColorAttributeName : UIColor.whiteColor(),
NSStrokeColorAttributeName : UIColor.blackColor()
]
Text becomes invisible when stroke is added
kCTStrokeWidthAttributeName。该属性被解释为字体点大小的百分比,控制文本绘制模式:正值影响仅使用笔画绘制;负值用于描边和填充。