2014-05-12 42 views

回答

1

不可以。這些屬性你不能改變,除非字體改變。因爲根據外觀代理可用鍵

  • UITextAttributeFont
  • UITextAttributeTextColor
  • UITextAttributeTextShadowColor
  • UITextAttributeTextShadowOffset

更改這些屬性自定義UINavigationBar的

如果您尋找字體更改,然後看下面的例子

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

試試這一個。

您必須自定義導航控制器並添加imageview

UIFont *yourFont = [UIFont fontWithName:@"Helvetica-BoldOblique" size:[UIFont systemFontSize]]; 

if ([[UINavigationBar class]respondsToSelector:@selector(appearance)]) { 
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"myimage.png"] forBarMetrics:UIBarMetricsDefault]; 
} 

[[UINavigationBar appearance] setTitleTextAttributes:@{ 
UITextAttributeTextColor : [UIColor clearColor], 
UITextAttributeTextShadowColor : [UIColor blackColor], 
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(1, 0)], 
UITextAttributeFont : yourFont 
}]; 

您可以使用:

  • 艦,BOLDITALIC
  • TimesNewRomanPS-BoldItalicMT
  • 巴斯克維爾-BOLDITALIC
  • HelveticaNeue-BOLDITALIC
  • TrebuchetMS粗體
  • 的Helvetica-BoldOblique
0

你可以試試下面的代碼,使您的文字斜體和大膽。

NSShadow *shadow = [[NSShadow alloc] init]; 
     shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8]; 
     shadow.shadowOffset = CGSizeMake(0, 1); 
     [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: 
                   [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName, 
                   shadow, NSShadowAttributeName, 
                   [UIFont fontWithName:@"HelveticaNeue-BoldItalic" size:21.0], NSFontAttributeName, nil]]; 

     [self setTitle:@"Title text"]; 
相關問題