0
votes

I am trying to modify a frame work and have encountered the following problem.

I have replaced one of the button image in the framework's xib file with my own one. The image itself is approximately 20Wx20H but I have set the button size to be 40Wx40H so that the clickable area is larger than the actual image.

When the VC is displayed, I see the image to be normal 20x20 aspect ratio. However, when I clicked on the button, it stretches to 40x20 and goes back to default upon release. I was wondering if there is a UIButton parameter that I can disable which was enabled by the framework somewhere? I have done a search on the buttons in the code and could not find anything relating to stretching the button. So I am guessing somewhere in IB there is my solution?

Below are the images for the button when touch down or not touched down.

button

1

1 Answers

0
votes

Have you tried the following?

button.imageView.contentMode = UIViewContentModeScaleAspectFit;

Also are you using autolayout? If yes, what are the constraints?