UIScrollView AutoLayout With 'Footer' Pinn

2019-09-10 02:47发布

问题:

I have been banging my head against a wall for a while with this. I need to have a UIScrollView with an arbitrary number of labels under each other and then have a header pinned to the top and a footer pinned to the bottom of the screen. All this needs to be using auto layout. Is this possible at all?

Any help would be appreciated Thanks,

Alex Crompton

回答1:

Yes, I believe it has to look like that

http://kernelmd.tumblr.com/image/114897924655

Just pin upper view to the top, bottom to the bottom, they must also have fixed sizes. Then for scroll view use relative vertical space to header and footer view.



回答2:

You can add header & footer view inside the scroll & add the labels in between & add constraints to header as top, leading, trailing, height. Then add constraint to labels as per your requirement & Finally add constraint to Footer view as leading, trailing, height & bottom. Bottom Constraint is must to know scrollView its content size.