ios - Zoom image returns to 1:1 if UIButton image is changed -


i have uibutton brush, , zoom.

if keep images same, both work well. images attached buttons in interface builder:

enter image description here

if change button image "draw", after zoom action, image return no zoom.

drawbutton.setimage(uiimage.init(named: "brush.png"), for: uicontrolstate.normal) 

how can change image without affecting zoom -- want able draw in zoomed mode.

i have tried this:

drawbutton.imageview?.image = uiimage.init(named: "brushyellow.png") 

this not affect zoom, not change image. ideas welcome please.

i tend use background image , force aspect ratio equal aspect of image on buttons. prevents pesky issues come referring to.

look @ actual aspect of photo , set constraint on storyboard aspect ratio of images dimensions. if creating programmatically, setting frame ratio should work well. make sure using

uibutton().setbackgroundimage(image: uiimage?, for: uicontrolstate)  

for changing image or have overlapping images. if need set multiple control states, so, find necessary other .normal

if need change constraint can create outlet , change multiplier 1:1 whatever should , back. if ui doesn't update may need call self.view.layoutifneeded()


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -