Recently I was looking to use the custom font SS-Standard
in a iOS application. After finding that the PostScript name is SSStandard
, adding the font ttf file to the project and adding to the .plist, I can change a UILabel by calling:
[myLabel setFont:[UIFont fontWithName:@"SSStandard" size:fontSize]];
This however only works in iOS7, and to make it work in iOS6 (and possibly below, I haven't tested though) I have to replace the above with:
NSMutableAttributedString *attributedString =
[[NSMutableAttributedString alloc] initWithString:myString
attributes:@{
NSFontAttributeName: [UIFont fontWithName:@"SSStandard" size:iconFontSize],
NSLigatureAttributeName: @2
}];
myLabel.attributedText = attributedString;
Now this all works fine, however I'm also trying to set a custom font within a UIBarButton
. I can do this for iOS7:
NSDictionary *barButtonAppearanceDict = @{
NSFontAttributeName : [UIFont fontWithName:SYMBOL_SET_NAME size:15],
NSLigatureAttributeName : @2
};
[button setTitleTextAttributes:barButtonAppearanceDict forState:UIControlStateNormal];
But for iOS6 it doesn't load the new font. I was wondering if anyone has ever come across this (with any custom font).