如何在PageViewController中更改ViewControllers框架位置?

时间:2016-06-09 06:41:18

标签: ios swift uipageviewcontroller

我编写的用于在页面视图控制器中加载视图控制器的代码。 以编程方式创建四个视图控制器并将其添加到页面视图控制器。 我已经更改了视图控制器的帧位置,但仍未在应用程序中更改

    let controller: UIViewController = UIViewController()
    print(controller.view.frame)
    controller.view.frame = CGRectMake(10, 20, self.view.frame.width/2, self.view.frame.height - 20)


    print(controller.view.frame)

    controller.view.backgroundColor = UIColor.blackColor()


    let controller2: UIViewController = UIViewController()
    controller2.view.backgroundColor = UIColor.redColor()

    let controller3: UIViewController = UIViewController()
    controller3.view.backgroundColor = UIColor.blackColor()

    let controller4: UIViewController = UIViewController()
    controller4.view.backgroundColor = UIColor.greenColor()

    let p1 = controller
    let p2 = controller2
     let p3 = controller3
    let p4 = controller4

    myViewControllers = [p1,p2,p3,p4]


    for index in 0 ..< myViewControllers.count {
        NSLog("\(myViewControllers[index])")
    }

    let startingViewController = self.viewControllerAtIndex(0)
    let viewControllers: NSArray = [startingViewController]

    self.setViewControllers(viewControllers as? [UIViewController], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: {(done: Bool) in
    })

0 个答案:

没有答案