使用 swift 的方式笔划轮廓数
Way stroke outline number using swift
是否有使用 swift 为 iOS 绘制或划数字的方法?数字必须采用大纲样式。提前致谢。
使用 NSAttributedString。 UITextField 可以使用 attributedText 属性.
显示属性字符串
let number = 5 // Whatever number you are looking to output
let font = UIFont.systemFontOfSize(12.0)
let attribs = [
NSForegroundColorAttributeName: UIColor.whiteColor(),
NSStrokeColorAttributeName: UIColor.blackColor(),
NSFontAttributeName: font,
NSStrokeWidthAttributeName: 1.0
]
let outlinedNumber = NSAttributedString(string: "\(number)", attributes: attribs)
玩转各种属性以获得您想要的效果。
是否有使用 swift 为 iOS 绘制或划数字的方法?数字必须采用大纲样式。提前致谢。
使用 NSAttributedString。 UITextField 可以使用 attributedText 属性.
显示属性字符串let number = 5 // Whatever number you are looking to output
let font = UIFont.systemFontOfSize(12.0)
let attribs = [
NSForegroundColorAttributeName: UIColor.whiteColor(),
NSStrokeColorAttributeName: UIColor.blackColor(),
NSFontAttributeName: font,
NSStrokeWidthAttributeName: 1.0
]
let outlinedNumber = NSAttributedString(string: "\(number)", attributes: attribs)
玩转各种属性以获得您想要的效果。