问题
I have set a cell image to my UITableViewCell
. It is a custom cell. I have set the aspect ratio as 1:1 and the width of the image view to 50. But for iphone 5 and 5s this size is too big as I feel. So how can I change the size of the UIImageView
relative to the screen width.
Please help me.
Thanks
This is my current view
回答1:
There are at least 2 ways you could configure image size based on the screen size:
Size-Classes allows you to set different width constraint value based on Trait Variation: Compact or Regular. Just select the width constraint, click on the Plus button on the left of it's Constant value and add a new variation for the iPhone device screens.
Manual approach with Aspect Ration constraint. This way you should select both ImageView and cell's ContentView, create "Equal Width" constraint and change it's multiplier value. Start with a 1:5 value - looking good.
来源:https://stackoverflow.com/questions/44941325/aspect-ratio-constraint-relative-to-the-screen-width