0

I am trying to add an image into the left bar button, but the image is being stretched even though the rect is 30x30. Any idea why this is happening or how to fix it? enter image description here

button.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
button.layer.cornerRadius = button.bounds.size.height / 2
button.clipsToBounds = true
button.imageView?.contentMode = .scaleAspectFill
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: button)
joethemow
  • 1,641
  • 4
  • 24
  • 39
  • Check this post https://stackoverflow.com/questions/43546132/how-to-customize-the-navigation-back-symbol-and-navigation-back-text/43556837#43556837 – Joe Jun 23 '17 at 20:45
  • You have a problem setting up your image size.check that link again and the link is entirely related to your question. – Joe Jun 23 '17 at 21:02
  • The Image is coming from my database and being downloaded. – joethemow Jun 23 '17 at 21:03
  • You ImageView frame is good. But, as you can see on your screenshot, your *button* frame is wrong. – Vasilii Muravev Jun 23 '17 at 21:53
  • Did I miss something? You set the frame 30x30, but in the screenshot you provided, I saw a rectangular shape with rounded corner button. How come? Why not square with rounded corner? – Gray Jun 24 '17 at 01:40
  • That is what I am stuck on. @Gary – joethemow Jun 24 '17 at 05:48

1 Answers1

0

Was this problem ever solved? I never had this problem as soon as I updated to swift 4 I'm having this issue and cannot find a fix.

OnlyDanWilliams
  • 342
  • 3
  • 9