mohn93/AdvancedPageControl

Is there any way to alignment left or right

asadali737 opened this issue ยท 3 comments

First of all, great work!!! ๐Ÿ‘

Secondly, there's no alignment property available to align the pageControlView to left or to right. It always by default displayed on the center of the container view. Is there any way to achieve this?

I have been trying to implement it to left. Were you able to find any solution? @asadali737

Use this for a left alignment:

func getCenteredXPosition(_ rect: CGRect, itemPos: CGFloat, dotSize: CGFloat, space: CGFloat, numberOfPages: Int) -> CGFloat {
  let individualDotPos = (itemPos * (dotSize + space))
  return individualDotPos
}

And this for a right alignment:

func getCenteredXPosition(_ rect: CGRect, itemPos: CGFloat, dotSize: CGFloat, space: CGFloat, numberOfPages: Int) -> CGFloat {
  let individualDotPos = (itemPos * (dotSize + space))
  let allDotsWidth = (CGFloat(numberOfPages) * dotSize + CGFloat(numberOfPages - 1) * space)
  return rect.width + individualDotPos - allDotsWidth
}

@rmnblm Thanks for your solution, It's working perfectly.

Do you have any idea about how can I increase the width of selected page?