2012-11-09 24 views
0

我這樣做:如何使UINavigation欄文本垂直居中

[[UINavigationBar appearance] setTitleTextAttributes:@{UITextAttributeTextColor: navTextColor,UITextAttributeTextShadowColor: navTextColor,UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],UITextAttributeFont: [UIFont fontWithName:@"HelveticaNeue-Bold" size:12],UITextAttributeFont: [UIFont fontWithName:@"HelveticaNeue-Bold" size:12]}]; 

結果是文字較小。但是,它張貼得太高。

enter image description here

我可以修復使用

[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:5 forBarMetrics:UIBarMetricsDefault]; 

但有時我想用UIText而非於titleview只是圖片和太下推。

這將是一個非常奇怪的設計,我認爲文本就像這樣上升。那麼有什麼問題,以及如何使UINavigationBar中的標題文本垂直居中,因爲它是水平的。

回答

1

一個解決方案是檢查this answer

其他的解決方案設置你的label viewframe。檢查this answer