user4809833
user4809833

Reputation:

How to change page view dots position in Swift?

I searched for this but cannot find any useful solution for me. How can I change my page view dots position by Y?

Now I have them on the bottom of my ViewController. How can make them +200 from the bottom?

I set up my dots here:

private func setupPageControl() {
    let appearance = UIPageControl.appearance()
    appearance.pageIndicatorTintColor = UIColor.grayColor()
    appearance.currentPageIndicatorTintColor = UIColor.whiteColor()
    appearance.backgroundColor = UIColor.darkGrayColor()
}

but when I've tried to:

appearance.layer.position.y = 200

it doesn't make a sense. All my controller code is here, if you want: http://pastebin.com/1hLRFPsR

Upvotes: 1

Views: 8137

Answers (2)

muazhud
muazhud

Reputation: 954

You need to have reference to the UIPageControl instance. Then you can basically manipulate the position of the pageControl. Refer to this code:

let pageControl = UIPageControl()
pageControl.pageIndicatorTintColor = UIColor.grayColor()
pageControl.currentPageIndicatorTintColor = UIColor.whiteColor()
pageControl.backgroundColor = UIColor.darkGrayColor()
pageControl.numberOfPages = 4
pageControl.center = self.view.center
self.view.addSubview(pageControl)

pageControl.layer.position.y = self.view.frame.height - 200; 
// 200 point from bottom of the screen

Upvotes: 5

user1585121
user1585121

Reputation:

If your current y position is :

appearance.layer.position.y

then to apply a modification relative to it do :

appearance.layer.position.y = appearance.layer.position.y +/- yourOffset

BUT you can't achieve that this way. More explications here https://stackoverflow.com/a/24933544/1585121 tl;dr UIPageViewController simplement his UIPageControl, and you can't mofidy its position

Upvotes: 1

Related Questions