1

I am new to iOS development. I am creating an application with TableViewController. On that screen I added a navigation bar too. I want the title and sub title,want to customize back button. I use the following code to add the title and sub title.

func setTitle(title:String, subtitle:String) -> UIView {
        let titleLabel = UILabel(frame: CGRectMake(0, 25, 0, 0))


        ....
        let subtitleLabel = UILabel(frame: CGRectMake(0, 54, 0, 0))
       ....
        let titleView = UIView(frame: CGRectMake(0, 0, max(titleLabel.frame.size.width, subtitleLabel.frame.size.width), 95))

        .....

        return titleView
    }

Above code working fine. Now I want to customize the back button. My origional design should the following screenshot enter image description here. But my output not simillar it is like the following screenshot enter image description here.

I am also using the following code to change the back button style

    navigationController!.navigationBar.barTintColor = UIColor(red: 224/255, green: 224/255, blue: 224/255, alpha: 1.0)
 navigationController?.navigationBar.backIndicatorImage = UIImage(named: "back_button")
        self.navigationController!.navigationBar.backItem!.title = "";
//        self.navigationController!.navigationBar.backItem!
        navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "back_button")

Why my back button is different. Please someone help me to find out the issue.

1 Answer 1

1

set the navigation bar button item tint colour to white or default... and check may be it will solve your problem

if you are using story board then open storyboard - Then Click the view where you have set the navigation bar image - click on that image - open attribute inspector - set the tint colour and if you have set it programatically then

 self.navigationBar.barStyle = UIBarStyle.Black
 self.navigationBar.tintColor = UIColor.whiteColor()
Sign up to request clarification or add additional context in comments.

3 Comments

if you are using story board then open storyboard - Then Click the view where you have set the navigation bar image - click on that image - open attribute inspector - set the tint colour and if you have set it programatically then self.navigationBar.barStyle = UIBarStyle.Black & self.navigationBar.tintColor = UIColor.whiteColor()
I am not using storyboard for this. I tried your code not working.
have you edited this.... navigationController!.navigationBar.barTintColor = UIColor(red: 224/255, green: 224/255, blue: 224/255, alpha: 1.0) with the above code...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.