Skip to content

Instantly share code, notes, and snippets.

@veeneck
Last active January 9, 2018 05:35
Show Gist options
  • Save veeneck/fd7928b86d695aae4465 to your computer and use it in GitHub Desktop.
Save veeneck/fd7928b86d695aae4465 to your computer and use it in GitHub Desktop.
outline text uilabel
if let font = UIFont(name: "DamascusSemiBold", size: 24) {
let textFontAttributes = [
NSFontAttributeName : font,
// Note: SKColor.whiteColor().CGColor breaks this
NSForegroundColorAttributeName: UIColor.whiteColor(),
NSStrokeColorAttributeName: UIColor.blackColor(),
// Note: Use negative value here if you want foreground color to show
NSStrokeWidthAttributeName: -3
]
myMutableString = NSMutableAttributedString(string: "hello world", attributes: textFontAttributes)
let label = UILabel(frame: CGRect(origin: CGPoint(x:500, y:500), size: CGSize(width: 200, height: 100)))
label.attributedText = myMutableString
self.view?.addSubview(label)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment