【问题标题】:NSForegroundAttributeName not working. Text fill renders transparentNSForegroundAttributeName 不起作用。文本填充呈现透明
【发布时间】:2015-05-20 08:15:54
【问题描述】:

我正在尝试将此文本的填充设置为白色,但填充是透明的,当我更改 NSForegroundAttribureName 时,它​​没有效果下面是我的代码。

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

在 viewDidLoad() 中

textFieldTop.defaultTextAttributes = textAttributes

如何将字体填充为白色?

【问题讨论】:

    标签: ios swift uikit


    【解决方案1】:
    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。此属性解释为字体点大小的百分比,控制文本绘制模式:正值仅影响描边绘制;负值用于描边和填充。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 2016-10-12
      • 2014-10-12
      相关资源
      最近更新 更多