【发布时间】:2014-06-02 10:38:52
【问题描述】:
我的 IOS 应用上有一个导航栏。我正在尝试更改 IPAD 的导航栏文本,但是虽然我可以更改导航栏字体,但我无法更改字体大小。请有人可以让我知道我哪里出错了。请在下面找到代码:
if ([self isIPAD ])
{
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil, [UIFont fontWithName:@"Helvetica" size:28], NSFontAttributeName, nil];
[[UINavigationBar appearance] setTitleTextAttributes:attributes];
}
else
{
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[[UINavigationBar appearance] setTitleTextAttributes:attributes];
}
【问题讨论】:
-
只需删除 attritube 中用于 ipad 条件的额外“nil”。它是 NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, **nil**(去掉这个), [UIFont fontWithName:@"Helvetica" size:28], NSFontAttributeName, nil];
标签: objective-c ios7 uinavigationbar