2016-05-18 32 views
0

我想在我的導航欄標題中設置2種顏色。 如果我不能這樣做,我怎麼能完美地集中一個圖像作爲我的導航欄的標題?我可以在我的導航欄中添加2種顏色Tittle嗎?

我想:

let logo = UIImage(named: "[email protected]"); 
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 100, height: 30)) 
imageView.image = logo 
imageView.contentMode = UIViewContentMode.ScaleAspectFit 
self.navigationItem.titleView = imageView 

它看起來那麼小,不集中。

謝謝你們!

+0

有很多關於如何在SO應用各種屬性的例子。爲了設置它然後:http://stackoverflow.com/questions/20310929/how-to-set-kerning-on-uinavigationbar-title – Larme

回答

0

感謝用戶Larme,你的回答幫了我很多。多數民衆贊成在我如何做到這一點:

let A = NSMutableAttributedString(string: "Label Test", attributes: [NSFontAttributeName: UIFont(name: "Georgia", size: 18)!]) 

A.addAttribute(NSForegroundColorAttributeName, value: UIColor.blueColor(), range: NSRange(location: 6, length: 5)) 

let LabelTexto: UILabel = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 30)) 

LabelText.attributedText = A 

self.navigationItem.titleView = LabelText 
相關問題