I recently added a scrollwall for my view controller
(I showed the red red background to the UIScrollView, to show that it is taking the full screen)
Now I have a lot in this scene but to keep it simple, I'll focus on the blue bar, which is called my app "topbar"
First of all, I define.
var topBar = UIView ()
I'm auto resizing, give it a color and add it to my scroll weave.
// ---- ------------- Topbar --------------- // Topbreststationletsautorerisingmask activation ( False) Topbars Background Corolr = Uaisilrkformulaalvr (blog) self.scrollView Add viewsview (topbar)
Add it to my ideas:
var viewsDictionary = [ "topbar Add: Height
to my metrics:
Let's get metrics extension = ["topbar height"]: 6]
< / Pre>Set the height in a size barrier.
// size reduction self.scrollView.addConstraints (NSLayoutConstraint.constraintsWithVisualFormat ( "V: [topbar (topBarHeight)]", Options: NSLayoutFormatOptions (0), Matrix: metricsDictionary, consider: V I \\\\\ '>
And what does not work at the end I / try / to create the full width of this "scrollview"
// horizontal restriction self.scrollView.addConstraints (NSLayoutConstraint.constraintsWithVisualFormat ( "H: | [topbar] |", option:
// vertical restrictions self.scrollView .addConstraints (NSLayoutConstraint.constraintsWithVisualFormat ( "V: | [Topbar] ", option: zero, matrix: zero, witch Now: for my scrollview (one that probably causes headache of my layout)
Set as: first thing in the class:
My viewDidLoadscrollView = UIScrollView (frame: UIScreen.mainScreen () range)
first thing ()
self.view.addSubview (scrollview) scrollView.setTranslatesAutoresizingMaskIntoConstraints (. Wrong) scrollView.scrollEn = disabled = true
and finally my viewDidLayoutSubviews
override function viewDidLayoutSubviews () {super.viewDidLayoutSubviews () scrollView.frame = view.bounds scrollView.contentSize = CGSize (width: 2000, height: 5678)}
^ The width of ContentSize will be changed to the width of the screen (I only want to scroll vertical). But now this is a minor issue compared to layout problems
With any help, why everything is squeezed will be greatly appreciated!
I managed to recover from doing this.
viewDidLayoutSubviews
override function viewDidLayoutSubviews () {super.viewDidLayoutSubviews () scrollView.frame = view.bounds scrollView.contentSize = CGSize (width : Self.view.bounds.width, height: 5678}}
And instead of creating a scene equal to scrollview, I had to create a subview about it.
I had to do a subviewview of ScrollView to work with all of my stuff, properly barriers.
self.view.addSubview (scrollView) scrollView.translatesAutoresizingMaskIntoConstraints = false content view. Tronssletsatorisijingmsk Inconstress = false scrollView.addSubview (contentView)
and were not Updrishy all my other goods "content view" and Scrolwuyr.
No comments:
Post a Comment