Jonathan
Jonathan

Reputation: 913

UIFont API to simplify font style modification?

I search an API to simplify the iphone font style modification (bold,italic,boldItalic etc) in an UILabel. Anybody have an idea?

Upvotes: 1

Views: 419

Answers (1)

Amy Worrall
Amy Worrall

Reputation: 16337

As far as I know, you can't do that with a UIFont using public methods.

There's a private method that does it, but of course you couldn't use that in an App Store app:

+(UIFont*)fontWithFamilyName:(NSString*)familyName traits:(GSFontTraitMask)traits size:(CGFloat)fontSize;

If you were using Core Text, you could create the font as a CTFontRef, then use CTFontDescriptorCreateCopyWithAttributes() with kCTFontTraitsAttribute set to kCTFontBoldTrait or kCTFontItalicTrait etc, which would get you a bold or italic version of the font you first created. Then I suppose you could do something like this to convert it into a UIFont. It's a bit of a cumbersome solution though.

Upvotes: 1

Related Questions