【发布时间】:2013-04-18 07:10:27
【问题描述】:
长话短说,这就是我得到的:
http://img839.imageshack.us/img839/9461/capturedcran20130418000x.png
这是我的 AppDelegate 中的一些代码:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"main_bar.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
//[UIColor colorWithRed:125.0/255.0 green:111.0/255.0 blue:100.0/255.0 alpha:1.0],
//UITextAttributeTextColor,
//[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],
//UITextAttributeTextShadowColor,
//[NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
//UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Pacifico" size:25],
UITextAttributeFont,
nil]];
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-10 forBarMetrics:UIBarMetricsDefault];
可能是什么问题?
【问题讨论】:
-
如果 Pacifico 是自定义字体,问题是 iOS 没有将它正确地居中在 y 轴上,这将导致它被截断,请参阅我关于主题 here 的帖子
-
标签看起来更像是被剪掉了。所以我的方法是创建一个 UILabel,使其大小与导航栏大小一样大,将默认标题设置为 nil,然后将标签添加到导航栏。
-
是的 Pacifico 是一种自定义字体。我应该使用什么方法? (我总是得到同样的错误:无法识别的选择器发送到实例......)
-
问题是我必须根据用户的选择放置动态标题...您的解决方案似乎不可能@pmk
-
我可以看到你在导航栏添加文本时的代码吗?
标签: ios objective-c navigationbar