I'm trying to place a UIImageView at the top of a UIScrollView and when I constrain the UIScrollView to the sides of the View Controller and constrain the UIImageView to the top and make the width of the UIImageView equal to the UIScrollView it makes the UIImageView way wider than the UIScrollView, and much taller than expected. Any idea what I'm doing wrong?
Storyboard:
Preview:
Check that following constraints are added to your view:
I have created one demo as you described.
Set all constraints for UIScrollView
and UIImageView
and works perfectly.
Below are reference images for you.
Step - 1 : In storyboard Select UIView
-> Editor -> Resolve layout issues
Step - 2 : Repeat same to add constraint
Step - 3 : Select UIScrollView
and add constraint from right-bottom corner
Step - 4 : Select UIImageView
and add constraint for it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.