Get Font Weight in iOS 14

0 votes

In iOS 13 and low I got Font.Weight using this extension for UIFont

var weight: UIFont.Weight {
    guard let traits = fontDescriptor.object(forKey: .traits) as? [UIFontDescriptor.TraitKey: Any], let weightValue = traits[.weight] as? CGFloat else { return .regular }
    let weight = UIFont.Weight(rawValue: weightValue)
    return weight
}

But since iOS 14 weightValue is wrong. For example:

let font = UIFont(name: "AvenirNext-Bold", size: 21)
print(font?.weight.rawValue)
print(font?.weight == .bold)

iOS 14 - 0.40000000000000002 false

iOS 13 - 0.40000000596046448 true

Anybody faced with it?


 

Nov 22 in Mobile Development by gaurav
• 22,040 points
23 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Mobile Development

0 votes
0 answers
0 votes
0 answers

How to get original image when we zoom in and zoom out the image in ios

Hi i am beginner in ios and ...READ MORE

Nov 17 in Mobile Development by gaurav
• 22,040 points
17 views
0 votes
0 answers

How to get the user's country calling code in iOS?

I am developing an iOS app in ...READ MORE

Nov 22 in Mobile Development by gaurav
• 22,040 points
19 views
0 votes
0 answers

Accurate timing in iOS

I am looking at the 'Metronome' sample ...READ MORE

Nov 8 in Mobile Development by gaurav
• 22,040 points
34 views
0 votes
0 answers

Swift - Find antilog for 4 digit Integer in iOS

I need to find an antilog for 5995. ...READ MORE

Nov 8 in Mobile Development by gaurav
• 22,040 points
37 views
0 votes
0 answers

Facebook log in keep redirecting in iOS

I have an Unity application using Facebook ...READ MORE

Nov 8 in Mobile Development by gaurav
• 22,040 points
37 views
0 votes
1 answer

How to build a font generator in iOS Swift and allowing pasting to clipboard

On your iPhone, you cannot copy and ...READ MORE

answered Sep 22 in IOS by Rahul
• 9,680 points
81 views
0 votes
0 answers

How to build a font generator in iOS Swift and allowing pasting to clipboard

I'm now building a listview to display ...READ MORE

Sep 23 in Others by gaurav
• 22,040 points
63 views
0 votes
0 answers

iOS 13 Custom Fonts download and installation

THIS IS NOT A DUPLICATE QUESTION I have ...READ MORE

Nov 22 in Mobile Development by gaurav
• 22,040 points
27 views
0 votes
1 answer

Any rate limiter for kitura

Try using KituraLimiter as a rate limiting ...READ MORE

answered Jun 4, 2018 in DevOps Tools by DareDev
• 6,890 points
248 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP