0

So I have upgraded to swift 4 and now my left & right uiimageviews set as left/right nav button items are showing as large icons. I have figured out that the Frame setting is not being applied and I am not sure why.

Does anyone know what may cause this?

Here is some code

    lazy var leftBarPic: UIImageView = {

        let pic = UIImageView(frame: CGRect(x: 0, y: 0, width: 25, height: 25))
        pic.clipsToBounds = true
        pic.contentMode = .scaleAspectFit
        pic.image = myImage.withRenderingMode(.alwaysOriginal)
        pic.isUserInteractionEnabled = true
        pic.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(postNewsAction)))
        pic.backgroundColor = .green

        return pic


    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftBarPic)

    }
3stud1ant3
  • 3,586
  • 2
  • 12
  • 15
Anthony
  • 3
  • 1

1 Answers1

0

OK I found a fix. For anyone having similar, what I did was add the property (in this instance the left navigator imageView) to the view's subview. Then added the constraints for width and height. It seems that with the upgrade setting the frame for nav items (image views only) inside the property does not work.

Anthony
  • 3
  • 1