【发布时间】:2018-04-20 05:56:01
【问题描述】:
我有一个显示UIPageViewController 的容器视图。一切正常,唯一的问题是显示页面的点。他们无法适应不断变化的屏幕尺寸。
pageControl = UIPageControl(frame: CGRect(x: 0,y: UIScreen.main.bounds.maxY - 525,width: UIScreen.main.bounds.width,height: 50))
这是我用来更改点显示位置的代码,主要是UIScreen.main.bounds.maxY - 525 部分。我只是在检查如何让它们适应不同的屏幕尺寸。下面是问题的屏幕截图。第一个橙色屏幕在我想要点的位置上是正确的,而第二个是错误的。
更多代码
func configurePageControl() {
// The total number of pages that are available is based on how many available colors we have.
pageControl = UIPageControl(frame: CGRect(x: 0,y: UIScreen.main.bounds.maxY - 525,width: UIScreen.main.bounds.width,height: 50))
self.pageControl.numberOfPages = orderedViewControllers.count
self.pageControl.currentPage = 0
self.pageControl.tintColor = UIColor.black
self.pageControl.pageIndicatorTintColor = UIColor.white
self.pageControl.currentPageIndicatorTintColor = UIColor.black
self.view.addSubview(pageControl)
}
我如何称呼视图
lazy var orderedViewControllers: [UIViewController] = {
return [self.newVc(viewController: "sbBlue"),
self.newVc(viewController: "sbRed")]
}()
【问题讨论】:
-
查看约束
-
它以编程方式设置,我添加了更多代码
-
您是否引用了希望 PageControl 调整到的视图? (即橙色或绿色视图)
-
@LukasBimba,你想为任何屏幕尺寸调整垂直位置,对吗?
-
我正在使用情节提要 ID 调用视图,也许我只需要找出另一种方法来完成我想要的外观?
标签: ios swift uipageviewcontroller uicontainerview