使用 UIAppearance 更改标签高度
有没有办法使用 UIAppearance 更改 UINavigationBar 内标签的高度。这是代码和正在发生的情况的图像,以便您可以了解问题所在。
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-5.0 forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-5.0 forBarMetrics:UIBarMetricsLandscapePhone];
NSDictionary *textAttributes = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[UIFont fontWithName:@"MarketingScript" size:34.0], nil]
forKeys:[NSArray arrayWithObjects:UITextAttributeFont, nil]];
Is there any way to use UIAppearance to change the height of a label inside of a UINavigationBar. Here's the code and an image of what's going on so you can understand what the problem is.
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-5.0 forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-5.0 forBarMetrics:UIBarMetricsLandscapePhone];
NSDictionary *textAttributes = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[UIFont fontWithName:@"MarketingScript" size:34.0], nil]
forKeys:[NSArray arrayWithObjects:UITextAttributeFont, nil]];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终通过创建自定义 UIView:
然后在 navigationItem 上设置 titleView 属性来解决此问题:
I ended up solving this by creating a custom UIView:
and then setting the titleView property on the navigationItem:
也许您可以在 UINavigationBar 中获取 UILabel 的 UIAppearance。
Probably you can get the UIAppearance for UILabel inside UINavigationBar.