2015-05-20 31 views
1

我想使這個文本的填充爲白色,但填充是透明的,當我更改NSForegroundAttribureName時,它沒有效果,下面是我的代碼。NSForegroundAttributeName不起作用。文字填充呈現透明

let textAttributes = [ 
    NSFontAttributeName : UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!, 
    NSStrokeWidthAttributeName : 3.0, 
    NSForegroundColorAttributeName : UIColor.whiteColor(), 
    NSStrokeColorAttributeName : UIColor.blackColor() 
] 

在viewDidLoad中()

textFieldTop.defaultTextAttributes = textAttributes 

如何讓我的字體填充白色的?

回答

2
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。此屬性解釋爲字體磅值的百分比,用於控制文本繪圖模式:正值僅影響繪圖;負值是筆畫和填充。

+0

這工作。謝謝! – Horatio