1

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

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
Jonathan
  • 873
  • 3
  • 9
  • 23

1 Answers1

1

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.

Community
  • 1
  • 1
Amy Worrall
  • 16,250
  • 3
  • 42
  • 65