Autolayout 16:9 animated GIF in Storyboard Xcode 1

2019-08-27 19:04发布

I'm having a Universal app and wanted to add a little tutorial. For that I have created a 16:9 animated GIF. I wanted to position that top/left or top/right. Text and buttons wherever space is left.

The image is initially 400x225, but I can accept any size, as long as 16:9 is kept.

I cannot figure out, how I could align that so that on phones it uses a smaller rect as on an iPad.

1条回答
Lonely孤独者°
2楼-- · 2019-08-27 19:19

If I understand correctly, you want the UIImageView to keep the same ratio.

You can do it using constraints, here’s how you should do it using your storyboard

Adding aspect ratio constraint

Setting ratio multiplier

If you want to stick it to the top left/right corner you should also add a constraint to the top of the superview- in order to stick it to the top, and a leading/trailing one to stick it to the left/right

查看更多
登录 后发表回答