Build a good project, came to storyboard, open to engage.
First set up the vertical screen
Drag a scrolling view into the storyboard Uiscrollview
Because this side is just demo, so directly to ScrollView Plus, left, bottom, right constraint is 0;
Update now to get the following effect
The next step is the point!
We dragged a uiview into the ScrollView.
Now let's constrain the view.
Let's set the constraint on, left and right, all 0.
But we found that we didn't have enough constraints to constrain him.
What's missing? What we're going to do here is roll up and down, with a little height? Now let's give him a height. Big enough, this way. Height setting 1200
After adding the height, we found that it was still a little unexpected and did not complete the constraint additions.
What to do, we now add a vertical center to the view
Now get this constraint
is still not added to complete, here to say, because our view is added to the ScrollView, although we set the view to the height, in other cases, we join the upper, left, right constraints, and then add height is can constrain a control, or the location of the view.
But here we have to add a next constraint, we give 100
Now, let's see our controller view.
It is not so good.
Why are you feeling more? This is the offset of the scrollview that we set by setting the constraint on the view
In order to make the text adaptive, we drag the view into the Uilabel
We give the label the upper, left, and right constraints, respectively giving the 100,30,30
The focus of text adaptation is to not set the number of lines of text
We set the label's lines property to 0
Now we change the label to the article we posted, in order to achieve the effect, we paste enough
We're going to run now and look at
did not achieve any adaptive effect ah? Isn't it deceptive? Our text is a part of the invisible, we recall before, we give ScrollView set the scroll distance, that is, the height of the view is not set to 1200, so we now scroll area, is 1200, see the text height is only 1100, Because we constrain the label at the time the constraint is 100.
Now we go back to storyboard. Select View
Remove the constraint of the height you added earlier,
Get the following effect
Let's set the altitude again, how do we set it?
Do we add 100 to the height of the text to get how high we view?
We set the height of the view to the height of the label, drag the View right button onto the label, select Equal Heights,
And then get the following effect
Now we run it again
Is this the right time?
During this time, some people may wonder why the previous constraint on the view was set to 100, and now the text clings to it, because we set the label constraint to 100 when we set it.
Let's change the current view to the next constraint change to 200
Now run, is not the text is not so awkward?
I would like to help the developers who have just contacted storyboard, there are a lot of shortcomings to hope for ideas and suggestions. If you have any questions, please leave a message. Thank you
Storyboard implementation of simple text adaptive