From 27db7f45fb59ce8d361ee3220ff40c012fce1ee9 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 19 Nov 2019 18:07:38 +0800 Subject: [PATCH] feat:iOS Slider paging effect --- iOS/Pod/Classes/Shader/DoricSliderNode.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iOS/Pod/Classes/Shader/DoricSliderNode.m b/iOS/Pod/Classes/Shader/DoricSliderNode.m index 1ccf6cbc..540d457c 100644 --- a/iOS/Pod/Classes/Shader/DoricSliderNode.m +++ b/iOS/Pod/Classes/Shader/DoricSliderNode.m @@ -70,6 +70,7 @@ - (UICollectionView *)build { collectionViewLayout:flowLayout] also:^(UICollectionView *it) { it.backgroundColor = [UIColor whiteColor]; + it.pagingEnabled = YES; it.delegate = self; it.dataSource = self; [it registerClass:[DoricCollectionViewCell class] forCellWithReuseIdentifier:@"doricCell"]; @@ -181,4 +182,9 @@ - (void)blendSubNode:(NSDictionary *)subModel { }]; } } + +- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { + NSUInteger pageIndex = (NSUInteger) (scrollView.contentOffset.x / scrollView.width); + scrollView.contentOffset = CGPointMake(pageIndex * scrollView.width, scrollView.contentOffset.y); +} @end