Svg image file scaled losing it width and height ratio.

I tried set button's image with svg assets file, it can be recognized it xcode but it cannot maintain its width and height ratio when I put 3 buttons in stackview horizontally with fill equally distribution and height constraint. It can figure out the width of the image in the button with png file before, but it scaled to the whole width space of the button when I tried svg image file. I want to use svg file to scale to given height constraint and figure out it own width. Could anyone tell me how to make this happen?

Answered by ComeForSwiftUI in 678946022

I just figured it out, setting the content mode to aspect fit in the storyboard is not working but you have to set the content mode in code.

Accepted Answer

I just figured it out, setting the content mode to aspect fit in the storyboard is not working but you have to set the content mode in code.

Svg image file scaled losing it width and height ratio.
 
 
Q