Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smooth UIPageViewController integration #12

Open
ppamorim opened this issue Jan 20, 2020 · 5 comments
Open

Smooth UIPageViewController integration #12

ppamorim opened this issue Jan 20, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@ppamorim
Copy link
Contributor

Hi,

I would like to know if it's possible to use the delegate from UIPageViewController to control the X axis movement of this custom UISegmentedControl. This allows smooth transitions of pages.

Something like this can be done:

segmentedControl.pageViewController = self

So the segmentedControl listens the UIPageViewController and animate it automatically.

Thank you.

@TimOliver
Copy link
Owner

Hi @ppamorim!

Hmm, this is a super specific use-case. It's definitely possible to do, but it would require a fair bit of effort to access the page view controller's state, and map that to the segmented control.

This is a little too specific to be implemented inside the segmented control class. But instead, I'd suggest what you could do is implement your own controller object that is in charge of linking up the segmented control and the page view controller, and handling all of the state between the two.

If you wanted to directly attach the segmented control's handle to the page view controller, it would require you to access the internal scroll view of the page view controller.

To manually control the position of the handle, you could wrap the setSelectedIndex method in a UIViewPropertyAnimator object and manually advance or retreat the animation progress.

I hope that helped! Sorry I couldn't do more!

@ppamorim
Copy link
Contributor Author

@TimOliver Maybe just expose the X position of the current item selected so it's easier to modify? So we don't need to implement anything to handle the internal scroll view action direct.

@TimOliver
Copy link
Owner

That's not a bad idea! It would be pretty easy to make a property like thumbHorizontalOffest and segmentWidth to control the positioning and determine which segment is active.

I don't have the time to do commissioned new features, but if you want to try and add it as a PR, I'd be happy to guide you. :)

@TimOliver TimOliver added the enhancement New feature or request label Jan 29, 2020
@TimOliver
Copy link
Owner

Hi @ppamorim! @kim-kiori-d has created a PR with the aim of supporting what you were asking for. If you're still interested in this functionality, would you like to take a look at it? :)

@ppamorim
Copy link
Contributor Author

ppamorim commented Sep 1, 2020

@TimOliver I will do thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants