Shamsiddin Shamsiddin - 1 year ago 36
iOS Question

Can I set the `attributedText` property of `UILabel`

Can I set the

property of a
object? I tried the below code:

UILabel *label = [[UILabel alloc] init];
label.attributedText = @"asdf";

But it gives this error:

Property "attributedText" not found on object of type 'UILabel *'

#import <CoreText/CoreText.h>
not working

Answer Source

Unfortunately, UILabel doesn't support attributed strings. You can use OHAttributedLabel instead.

Update: Since iOS6, UILabel does support attributed strings. See UILabel reference or Michael Kessler's answer below for more details.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download