iOS autolayout to center my view between two views
How to set up autolayout in Interface Builder to arrange views vertically as shown on image:
Top view pinned to top screen edge,
Bottom view pinned to bottom screen edge.
My view should be centered between top and bottom views (so distance to
Top view equals to distance to
- Auto Layout constraint on CALayer IOS
- Working with AutoLayout in Portrait and Landscape
- Auto layout + size classes issue in swift
- table header view height is wrong when using auto layout, IB, and font sizes
- ImageView Scaling when scrolling down
- How to configure different layouts for Portrait and Landscape Orientations using Auto Layout?
2 Solutions Collect From Internet About “iOS autolayout to center my view between two views”
The way to do this is to have 2 invisible “spacer” views between you visible views.
You can’t make spaces have equal height. But you use the “spacer” views and place them between your views (with 0 gap to the surrounding views).
Then you give these views equal heights and they will push your views around to centre the
My View with equal gap to the
Bottom View and
i.e. like this…
V:|[Top View][spacer1][My View][spacer2(==spacer1)][Bottom View]|
EDIT – Another way
I just thought of another way of doing this. You could have an invisible container
UIView that is between
Top View and
Bottom View with no gap.
Then you place
My View inside this invisible view and centre it vertically.
One more solution is to add an invisible view between top view and botom view and place my view in center of this view:
- size class for table row height in iOS storyboard
- Unable to compile for iOS 10 after Sierra Update
- Getting the exact location of a UITableViewCell
- iOS: Using @min and @max in a core data predicate
- UIColor vs IB color (color profile issue)
- Rotate sprite by touch with a limited rotation speed
- scaleMode .fill not filling the scene view on iPad
- How to translate this objective c traitCollection to swift?
- Import Kanna in playground
- What does the property “Nonatomic” mean?
- How to align UILabel text from bottom?
- Is it possible to end an SKAction mid-action?
- How to maintain Timer to continue running when Home button is pressed
- How to use 2 UITableView in a UIViewController?
- Fatal Error: use of unimplemented initializer 'init(realm:schema:)'