Updated 10 January 2017
Suppose you want to show the image to the navigation bar in place navigation title.And it is useful when you want to show your application name in the UINavigationBar . Firstly, you have to create the object of UIImageView then you have to assign an image to the UIImageView object. After assigning object to the UIImageView, then you have to assign that object to the UINavigationBar titleView . Here is the example setting image in UINavigationBar :-
1 2 3 4 5 6 |
let img = UIImage(named: "logo.jpg")! let imgView = UIImageView(frame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(150), height: CGFloat(50))) imgView.image = img imgView.contentMode = .scaleAspectFit imgView.clipsToBounds = true self.navigationItem.titleView = imgView |
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.