有没有办法将导航栏中的标题更改为Italic,Bold和下划线而不更改字体? [英] Is there a way to change title in navigation bar to Italic, Bold and underlined without changing font?

查看:75
本文介绍了有没有办法将导航栏中的标题更改为Italic,Bold和下划线而不更改字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用UIAppearance在导航栏中更改标题的属性,如下所示:

I use the UIAppearance to change attributes of my title in Navigation Bar like so:

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [MM mainTitleColor]}];

但是我还没有找到使文字加下划线或斜体的方法,有没有办法做到这一点没有一直改变字体?

But I have not found the way to make text underlined or italic, is there a way to do this without changing the font alltogether?

推荐答案

没有。除非字体更改,否则您无法更改这些属性。因为外观代理下的可用键是

No. These properties you cant change unless font changing. Because the available keys under the appearance proxy are


  • UITextAttributeFont

  • UITextAttributeTextColor

  • UITextAttributeTextShadowColor

  • UITextAttributeTextShadowOffset

  • UITextAttributeFont
  • UITextAttributeTextColor
  • UITextAttributeTextShadowColor
  • UITextAttributeTextShadowOffset

更改这些用于自定义 UINavigationBar

的属性如果您要查找字体更改,请参阅以下示例

If you looking for font change, then see the below example

[[UINavigationBar appearance] setTitleTextAttributes:@{
    UITextAttributeTextColor: TEXT_COLOR,
    UITextAttributeTextShadowColor: SHADOW_COLOR,
    UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
    UITextAttributeFont: [UIFont fontWithName:@"Arial-Bold" size:0.0],
}];

这篇关于有没有办法将导航栏中的标题更改为Italic,Bold和下划线而不更改字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆