zepojo / UPCarouselFlowLayout

A fancy carousel flow layout for UICollectionView on iOS.
MIT License
1.66k stars 236 forks source link

connect carousel with pageView #23

Open Melf11 opened 7 years ago

Melf11 commented 7 years ago

hi, first of all, thanks for your work! the carousel is working nice for my app.

i want to connect the carousel with my pageView. My carousel just got a label with headings in it and when i swipe left or right i can change between different pageViews. Now i want to connect the heading-labels with my pages, like the pageViewController

so i want to swipe the headings "audio","netzwerk","player" together with the pageView it looks like this

pageviewcontroller kopie

Melf11 commented 7 years ago

hi, sorry, i solved my problem with https://github.com/PageMenu/PageMenu that is exaclty what i was searching for. but thanks anyway for your programm!

Bertges commented 6 years ago

I know it has been asked a long time ago, but if anyone face this problem too, I solved it by getting the indexPath of the center UICollectionViewCell.

func scrollViewDidScroll(_ scrollView: UIScrollView) {
        let center = CGPoint(x: scrollView.contentOffset.x + (scrollView.frame.width / 2), y: (scrollView.frame.height / 2))
        if let ip = self.collectionView!.indexPathForItem(at: center) {
            self.pageControl.currentPage = ip.row
        }
}