0

I want to set 2 colours in my navigation bar title. If i cant to do that, how can i center perfectly an image as tittle of my navigation bar?

I tried:

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

And it looks so small and not centered.

Thanks guys!

Lucas Palaian
  • 374
  • 2
  • 12
  • There are plenty of example on how applying various attributes in SO. For setting it then: http://stackoverflow.com/questions/20310929/how-to-set-kerning-on-uinavigationbar-title – Larme May 18 '16 at 08:10

1 Answers1

0

Thanks user Larme, your answer helped me a lot. Thats how i do it:

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
Lucas Palaian
  • 374
  • 2
  • 12