I want to set the border with white color to label texts, and I used the NSAttributedString, set both strokeWidth&strokeColor, but when I run the project, the result is too wired with text "2" and "6", is there any wrong with it or who know the reason for it, thanks! I'm using Xcode 13.4.1(13F100)
The all codes is here
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let testLabel = UILabel()
testLabel.frame = CGRect(x: 20, y: 100, width: 400, height: 100)
view.addSubview(testLabel)
let attributes: [NSAttributedString.Key: Any] = [
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 88, weight: .black),
NSAttributedString.Key.strokeWidth: -2,
NSAttributedString.Key.foregroundColor: UIColor.orange,
NSAttributedString.Key.strokeColor: UIColor.white
]
testLabel.attributedText = NSAttributedString(string: "123456", attributes: attributes)
}