最後に、私は自分の解決策を書きました。
https://stackoverflow.com/a/12281017/1565615 @Nathan R.がフォントサイズの取得を手伝ってくれました。
次に、UIFont 記述の font-weight コンポーネントを抽出し、それに応じてフォントを変更しました。これは、ストーリーボードでフォント サイズとスタイルを設定できるようになり、UILabel のサブクラス化されたバージョン内で設定できるようになったため、カスタム フォントに最適です。
font.fontWeight のように使用されている font-weight のタイプを特定する簡単な方法があればいいのにと思います。
- (id)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self)
{
NSString *fontInfo = self.font.description;//Complete font description
NSArray *splitUpFontDescription = [fontInfo componentsSeparatedByString: @";"];//Split up
NSString *fontWeight = [[NSString alloc]init];
for (NSString *tempString in splitUpFontDescription)
{
if ([tempString rangeOfString:@"font-weight"].location != NSNotFound)//Font weight found
{
fontWeight = [tempString stringByReplacingOccurrencesOfString:@" "
withString:@""];//Remove whitespace
fontWeight = [fontWeight stringByReplacingOccurrencesOfString:@"font-weight:"
withString:@""];
}
}
NSLog(@"Font style (Weight) = *%@*",fontWeight);
if ([fontWeight isEqualToString:@"normal"])
{
//Set to custom font normal.
self.font = [UIFont fontWithName:@"FrutigerLT-Roman" size:self.font.pointSize];
}
else if([fontWeight isEqualToString:@"bold"])
{
//Set to custom font bold.
self.font = [UIFont fontWithName:@"FrutigerLT-Bold" size:self.font.pointSize];
}
}
return self;
}