diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..78c6777b Binary files /dev/null and b/.DS_Store differ diff --git a/Pods/Pods.xcodeproj/xcuserdata/xiaomage.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/xiaomage.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..7066051a --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/xiaomage.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,19 @@ + + + + + SchemeUserState + + Pods-SDCycleScrollView.xcscheme_^#shared#^_ + + orderHint + 1 + + SDWebImage.xcscheme_^#shared#^_ + + orderHint + 2 + + + + diff --git a/SDCycleScrollView.xcodeproj/xcuserdata/xiaomage.xcuserdatad/xcschemes/xcschememanagement.plist b/SDCycleScrollView.xcodeproj/xcuserdata/xiaomage.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..2523af60 --- /dev/null +++ b/SDCycleScrollView.xcodeproj/xcuserdata/xiaomage.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + SDCycleScrollView.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/SDCycleScrollView.xcworkspace/xcuserdata/xiaomage.xcuserdatad/UserInterfaceState.xcuserstate b/SDCycleScrollView.xcworkspace/xcuserdata/xiaomage.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..8f7b59d4 Binary files /dev/null and b/SDCycleScrollView.xcworkspace/xcuserdata/xiaomage.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.h b/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.h index 817b2f6a..8ed50c5a 100644 --- a/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.h +++ b/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.h @@ -154,6 +154,9 @@ typedef enum { /** 只展示文字轮播 */ @property (nonatomic, assign) BOOL onlyDisplayText; +/** 多行文字同时轮播显示,仅文字轮播有效 */ +@property (nonatomic, assign) NSUInteger lineCount; + /** pagecontrol 样式,默认为动画样式 */ @property (nonatomic, assign) SDCycleScrollViewPageContolStyle pageControlStyle; diff --git a/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m b/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m index 68741e88..abc74725 100644 --- a/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m +++ b/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m @@ -434,6 +434,9 @@ - (void)automaticScroll if (0 == _totalItemsCount) return; int currentIndex = [self currentIndex]; int targetIndex = currentIndex + 1; + if (self.onlyDisplayText && self.lineCount > 0 && self.scrollDirection == UICollectionViewScrollDirectionVertical) { + targetIndex = currentIndex + (int)self.lineCount; + } [self scrollToIndex:targetIndex]; } @@ -460,6 +463,9 @@ - (int)currentIndex index = (_mainView.contentOffset.x + _flowLayout.itemSize.width * 0.5) / _flowLayout.itemSize.width; } else { index = (_mainView.contentOffset.y + _flowLayout.itemSize.height * 0.5) / _flowLayout.itemSize.height; + if (self.onlyDisplayText && self.lineCount > 0) { + index = (_mainView.contentOffset.y + _flowLayout.itemSize.height * 0.5 + _flowLayout.itemSize.height * (self.lineCount - 1)) / _flowLayout.itemSize.height; + } } return MAX(0, index); @@ -488,7 +494,11 @@ - (void)layoutSubviews [super layoutSubviews]; - _flowLayout.itemSize = self.frame.size; + if (self.onlyDisplayText && self.lineCount > 0 && self.scrollDirection == UICollectionViewScrollDirectionVertical) { + _flowLayout.itemSize = CGSizeMake(self.frame.size.width, self.frame.size.height/self.lineCount); + }else{ + _flowLayout.itemSize = self.frame.size; + } _mainView.frame = self.bounds; if (_mainView.contentOffset.x == 0 && _totalItemsCount) { diff --git a/SDCycleScrollView/ViewController.m b/SDCycleScrollView/ViewController.m index 53303212..dfadd760 100644 --- a/SDCycleScrollView/ViewController.m +++ b/SDCycleScrollView/ViewController.m @@ -161,6 +161,24 @@ - (void)viewDidLoad { _customCellScrollViewDemo.imageURLStringsGroup = imagesURLStrings; [demoContainerView addSubview:_customCellScrollViewDemo]; + + + // >>>>>>>>>>>>>>>>>>>>>>>>> demo轮播图6 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + // 网络加载 --- 创建只上下滚动展示文字的轮播器 + // 由于模拟器的渲染问题,如果发现轮播时有一条线不必处理,模拟器放大到100%或者真机调试是不会出现那条线的 + SDCycleScrollView *cycleScrollView6 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 1000, w, 60) delegate:self placeholderImage:nil]; + cycleScrollView6.scrollDirection = UICollectionViewScrollDirectionVertical; + cycleScrollView6.onlyDisplayText = YES; + cycleScrollView6.lineCount = 2; + NSMutableArray *titlesArray1 = [NSMutableArray new]; + [titlesArray1 addObject:@"纯文字上下多行滚动轮播"]; + [titlesArray1 addObject:@"纯文字上下多行滚动轮播 -- demo轮播图6"]; + [titlesArray1 addObjectsFromArray:titles]; + cycleScrollView6.titlesGroup = [titlesArray1 copy]; + [cycleScrollView6 disableScrollGesture]; + + [demoContainerView addSubview:cycleScrollView6]; } - (void)viewWillAppear:(BOOL)animated