I search an API to simplify the iphone font style modification (bold,italic,boldItalic etc) in an UILabel. Anybody have an idea?
Asked
Active
Viewed 412 times
1
-
What do you mean by `simplify`? – rckoenes Jul 09 '12 at 09:10
-
1I mean for example instead of : UIFont *font = [UIFont fontWithName:@"Helvetica" withSize:25]; do : UIFont *font = [UIfont fontWithfamily:family style:Bold size:size]; – Jonathan Jul 09 '12 at 09:14
-
There is no API to simplify that. – rckoenes Jul 09 '12 at 09:16
1 Answers
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