我想知道如何在 VC 堆栈中向上移动 UIButton?
我的问题:
在我的 VC 中,我添加了一个页面 Controller View ,以便在图像之间滑动。但问题是当我这样做时,按钮卡在添加的页面 Controller View 后面。
添加页面 View Controller 时我的代码:
self.pageViewController.setViewControllers(viewControllers as [AnyObject], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)
self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)
self.addChildViewController(self.pageViewController)
self.view.addSubview(self.pageViewController.view)
self.pageViewController.didMoveToParentViewController(self)
这将导致按钮不显示/卡在页面 View Controller 后面。
我已经尝试在 Root View 和该 View 之前的按钮下添加第二个 UIView,然后通过以下方式将页面 View Controller 作为 subview 添加到该新 View :self.MyNewSubView.addSubview(self.pageViewController.查看)
这几乎行得通。该按钮显示在页面 View Controller 前面,但页面 View Controller 的自动布局变得困惑,因为它包含带有图像(放大/缩小)的 uiscroll View 。
我还尝试将 CGRectMake 设置为例如 CGRectMake(0,50),这有点管用。但问题是肖像中的大图像在底部被剪裁。
所以我想做的是在添加页面 View Controller 后将按钮推到堆栈上。
提前致谢
最佳答案
你可以要求你当前的 View bringSubviewToFront(button)
关于ios - 在 VC 堆栈中快速移动 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31632715/