Today I have a task with adjusting the center.y of the image view relative to 0.4 of the launch screen height.
As you know, it cannot be customized with view controllers because the launch screen is independent. This is why I am setting up the image view through the storyboard. On different screens, the image is displayed at different heights, since the rigidly anchored top constraint sets a specific value (270, for example). In my case, it is necessary that the launch screen itself counts 0.4 from the height of its view and set this value for the center of the image view.
How can I do this with storyboards?
Question posted in Xcode
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
2
Answers
You cannot set a center anchor in relation to a height. There is no such relationship.
Use an invisible spacer view with its top pinned to the top of the superview. The spacer view height can be set relative to the superview height, and now the image view vertical center can be set relative to the spacer view bottom.
First, add a center Y constraint like this:
The constraint’s second item would be Superview.Center Y. Change that to Superview.Bottom instead:
Because the superview in this case is the root view, its bottom will be equal to its height. Now you can change the multiplier to 0.4 to achieve the desired effect.