I have an image that I want to take up the entirety of the screen in a UIScrollView. However, to avoid clipping and distortion of the image I have the constraints set so the image will always have the correct aspect ratio. When you run this on different size screens, the image is different sizes. Is there some code I can program in to make my scrollview always the same height as my image? I need my scrollview to change depending on the height of the image since on different devices the height of my image will change.
so far I have:
class Second : UIViewController {
@IBOutlet weak var myScrollView: UIScrollView!
@IBOutlet weak var myImage: UIImageView!
override func viewDidLoad() {
ScrollView.contentSize.height = 1300
}
The constraints I used on the image are:
- Equal width as the scrollview
- entered horizontally in the scrollview
- Top space to the top of the scrollview
- Aspect fit (so the image is not distorted)
Thank you. Any help is very appreciated!