sending UIScrollView to Background

女生的网名这么多〃 提交于 2019-12-13 00:40:24

问题


I'm midway of finishing my app. I noticed that one of my views needs extra vertical space so I need to add a UIScrollView. Yet when I add that scroll view it overlaps everything else in the view. In simple words if I need to get it to work properly I have to delete everything off the view , add the scroll view, and then re-add everything back! Is there anyway to send this scroll view to the background of the view? This is all the code that concerns the scroll view

@IBOutlet var scrollerForPOfFourBar: UIScrollView!

override func viewDidLoad() {
    super.viewDidLoad()
    /* non related code here*/

    scrollerForPOfFourBar.userInteractionEnabled = true
    scrollerForPOfFourBar.self.contentSize = CGSizeMake(320, 400)
}

回答1:


I'm assuming you're using Interface Builder since you marked your scrollView as an IBOutlet.

On the view list, on the left, the order of the views specifies their Z order, with the views at the bottom being the ones drawn on top (with the largest Z).

To move your scrollView to the back, drag it just underneath of the view, and drop it there.

Keep in mind that you will have to drag all the views you had in your view into the scrollView (the easiest is to do it in the views navigator as well), and you'll have to set up any Auto Layout constraints again, which will be a pain.




回答2:


Are you just want to move scrollerForPOfFourBar to back? Try this:

self.view.sendSubviewToBack(scrollerForPOfFourBar)


来源:https://stackoverflow.com/questions/28992374/sending-uiscrollview-to-background

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!