1

didFinishLaunchingWithOptions:カスタム フォントを使用できるように、このコードを AppDelegate.m ファイルの下に置きます。

[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                        [UIColor grayColor], UITextAttributeTextColor,
                                                        [UIFont fontWithName:@"Gotham-Medium" size:10], UITextAttributeFont, nil] forState:UIControlStateNormal];

[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                        [UIColor whiteColor], UITextAttributeTextColor,
                                                        [UIFont fontWithName:@"Gotham-Medium" size:10], UITextAttributeFont, nil] forState:UIControlStateHighlighted];

フォントの変更は期待どおりに機能しますが、デバッグ コンソールに次の出力が表示されます。

button text attributes only respected for UIControlStateNormal, UIControlStateHighlighted and UIControlStateDisabled. state = 1 is interpreted as UIControlStateHighlighted.

4

1 に答える 1