覆盖视图/图像上的UIPageControl指示符(Swift)

时间:2014-11-04 00:22:05

标签: ios swift ios8 uipagecontrol

以下是我在视图控制器中显示基于页面的视图的代码

// Create page view controller
    self.pageViewController = UIPageViewController(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: nil)
    self.pageViewController.dataSource = self

    let startingViewController : PageContentViewController = self.viewControllerAtIndex(0)!
    let viewControllers: NSArray = [startingViewController]
    self.pageViewController.setViewControllers(viewControllers, direction: .Forward, animated: true, completion: nil)

 // Change the size of page view controller
        self.pageViewController.view.frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height - 140)

        self.addChildViewController(self.pageViewController)
        self.view.addSubview(pageViewController.view)
        self.pageViewController.didMoveToParentViewController(self)


                // Page control dots

    var pageControl = UIPageControl.appearance
    pageControl().pageIndicatorTintColor = UIColor.lightGrayColor()
    pageControl().currentPageIndicatorTintColor = UIColor.blackColor()
    pageControl().backgroundColor = UIColor.whiteColor()

    // First button from bottom . Thats why -70
    let button1 = UIButton.buttonWithType(UIButtonType.System) as UIButton
    button1.frame = CGRectMake(0, view.frame.height - 70, view.frame.width, 70)
    button1.backgroundColor = UIColor(red: 25/255.0, green: 134/255.0, blue: 237/255.0, alpha: 1)
    button1.setTitle("Button1", forState: UIControlState.Normal)
    button1.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
    button1.addTarget(self, action: "button1:", forControlEvents: UIControlEvents.TouchUpInside)
    button1
    self.view.addSubview(button1)

    // Right above twitter button. That why -140
    let button2 = UIButton.buttonWithType(UIButtonType.System) as UIButton
    button2.frame = CGRectMake(0, view.frame.height-140, view.frame.width, 70)
    button2.backgroundColor = UIColor(red: 148/255.0, green: 196/255.0, blue: 36/255.0, alpha: 1)
    button2.setTitle("Button2", forState: UIControlState.Normal)
    button2.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
    button2.addTarget(self, action: "button2:", forControlEvents: UIControlEvents.TouchUpInside)
    self.view.addSubview(button2)

这就是它的看法 - enter image description here

现在我想知道,如何在图像上添加页面指示符?作为叠加?所以没有空格。

由于

0 个答案:

没有答案