Than or equal to the height of the image container behind it (recall that our image container has the aspect ratio constraint). We then add an additional constraint: the height of our image must be greater This is necessary to achieve the effect we want.įirst, we keep our original constraint. Notice how we now have a top constraint, a bottom constraint, and a heightĬonstraint? This is one of the awesome things about Auto Layout: we can haveĬonflicting constraints and they will be broken in priority order. Pin the edges of the scroll view to// our view controller’s It also has a backing view which provides us with Our view controller’s view has a scroll view as its first subview, followed by the text and image views. Our views are declared as private members: private let scrollView = UIScrollView()private let infoText = UILabel()private let imageView = UIImageView()
![hide status bar ios swift hide status bar ios swift](https://cdn.educba.com/academy/wp-content/uploads/2020/02/React-Native-StatusBar.jpg)
Below you can see how the initial constraints are set.
#Hide status bar ios swift code#
Most of the code will live in viewDidLoad of our StretchyViewController class.
![hide status bar ios swift hide status bar ios swift](https://i.stack.imgur.com/jajgy.png)
It’s dead simple to use, and makes programming with Auto Layout genuinely pleasurable. SnapKit is a simple iOS framework that makes Apple’s Auto Layout API…sane. We’re going to build this using an Auto Layout framework called SnapKit. There’s also a UIScrollView and the root view of our view controller. The bright red lines represent our Auto Layout constraints. There’s the header UIImageView, which is the container for the text, and the long UILabel containing our text content. Here’s the view hierarchy for the basic version of the app.
![hide status bar ios swift hide status bar ios swift](https://i.stack.imgur.com/a4XXR.png)
You’ll need Xcode 9 as we’re going all-in on iOS 11 for this example. If you want to follow along, you can clone the demo project at our starting point and implement the effect as you read along. And Auto Layout makes its implementation so elegant that I think you ought to know about it. I wanted to write about this because the effect is so simple. This is a cool effect.Īnd it’s really easy to build in iOS using Auto Layout.
#Hide status bar ios swift how to#
By Enabled Solutions How to create beautiful Stretchy Layouts on iOS using Auto Layout and SnapKitĬheck the image below.