Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting issue on strokeWidth NSAttributedString in iOS 14

I have an issue with stroke color on iOS 14.

let attributes: [NSAttributedString.Key: Any] = [
    .foregroundColor: UIColor.white,
    .strokeColor: UIColor.black,
    .font: UIFont.systemFont(ofSize: 65, weight: .black),
    .strokeWidth: -1 
]
lableNumber.attributedText =  NSAttributedString(string: "2", attributes: attributes)

iOS 13

enter image description here

iOS 14

example

It is working on iOS 13 but not working in iOS 14. Can anyone help me to resolve this issue?

like image 945
vikas prajapati Avatar asked Oct 12 '20 12:10

vikas prajapati


Video Answer


1 Answers

Looks like Apple has changed the font outlines in iOS 14, the glyphs for 6 and 9 exhibit similar artifacts. I would file a bug with Apple.

Depending on your requirements, using UIFont.monospacedSystemFont(...) could work, those glyphs still look OK to me. (Edit: "1" has artifacts in the monospaced version as well. Maybe use UIFont(name: "HelveticaNeue-Bold", size: 65) instead?)

like image 77
Gereon Avatar answered Oct 21 '22 05:10

Gereon