lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
246 stars 17 forks source link

30049158: UILabel, UITextField and UITextView should have a textStyle property #16733

Open openradar-mirror opened 7 years ago

openradar-mirror commented 7 years ago

Description

Dynamic font on iOS is great, but it is still a lot of work to fully support it. One of the biggest and most annoying tasks when doing so is to listen to the UIContentSizeCategoryDidChangeNotification notification and update all the fonts in all the labels. In order to do this you need to have a reference to each label on the screen, you need to know what text style the given label should have and you need to update them all. If you are using interface builder this is particularly annoying as it kind of breaks with the pattern to have layout related things setup in interface builder, as you need to check for that notification and assign a new font in interface builder. But even if you don’t use interface builder, the fact that you need to reference every single label, text field and text view on the screen somewhere blows up the code and assigning the new fonts essentially just is a lot of boiler plate.

So some people, including myself, write a label that has a textStyle property and then change all their labels to be of type textStyle. This label does the following: Instead of assigning it a font, you assign it a UIFontTextStyle and then the label monitors the UIContentSizeCategoryDidChangeNotification itself and updates its font accordingly.

This is something that should be build into UIKit. It would be very helpful to have this available on every label without the need to change the base class of every label. Also Apple could do a far better support for interface builder on this than any other developer could do.

I am fairly sure that this would increase the amount of apps that properly support dynamic font a lot as it would dramatically decrease development time for this feature to almost no time as the only thing you need to do is instead of configuring a font you just set the text style.

- Product Version: 10.2 Created: 2017-01-17T08:43:11.795360 Originated: 2017-01-17T09:43:00 Open Radar Link: http://www.openradar.me/30049158

openradar-mirror commented 7 years ago

Modified: 2017-02-03T08:06:22.825280

openradar-mirror commented 7 years ago

Modified: 2017-02-03T08:06:22.825280

openradar-mirror commented 7 years ago

Modified: 2017-02-03T08:06:22.825280