Scaling UIImageView to fit screen width

前端 未结 1 665
無奈伤痛
無奈伤痛 2021-02-15 15:43

I have an UIImageView created using Storyboard inside UIViewController.

I\'m trying to rescale the width of the image to fit the screen width

1条回答
  •  误落风尘
    2021-02-15 16:34

    Try using this code:

    float imgFactor = frame.size.height / frame.size.width;
    frame.size.width = [[UIScreen mainScreen] bounds].size.width;
    frame.size.height = frame.size.width * imgFactor;
    

    0 讨论(0)
提交回复
热议问题