1

すべてのナビゲーション バーに一貫したタイトルの色を設定したかったのです。

NSDictionary *titleAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],
                                  NSFontAttributeName: MY_FONT_HERE};
[[UINavigationBar appearance] setTitleTextAttributes:titleAttributes];

このコードは iOS6 では機能しますが、ios7 ではクラッシュします。

クラッシュ メッセージは奇妙です。

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-                 [__NSCFConstantString pointSize]: unrecognized selector sent to instance 0x107c34'
4

1 に答える 1

1

MY_FONT_HERE は文字列値であると推測していますが、UIFont である必要があります。文字列を属性に渡す代わりに、フォントを で初期化し[UIFont fontWithName:MY_FONT_HERE]ます。

于 2013-09-26T18:51:04.057 に答える