Home / IOS Development / fast – Why not reset text attributes on iOS 13 to change the text of a UIL tag?

fast – Why not reset text attributes on iOS 13 to change the text of a UIL tag?



You did not reset attributedText, but documentation says – if specified, the label ignores the above properties (see below for UILabel.h interface, in obj-c it is more visible):

@property(null_resettable, nonatomic,strong) UIColor     *textColor UI_APPEARANCE_SELECTOR; // default is labelColor
...

// the underlying attributed string drawn by the label, if set, the label ignores the properties above.
@property(nullable, nonatomic,copy)   NSAttributedString *attributedText API_AVAILABLE(ios(6.0));  // default is nil

then behaves as specified (before there may be an error, which is now fixed)

The solution to your case should be

label.attributedText = attributedString        
...
label.attributedText = nil      // << reset to default !!
label.text = "What's up world"


Source link