Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SDCycleScrollView.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
3 changes: 3 additions & 0 deletions SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ typedef enum {
/** 只展示文字轮播 */
@property (nonatomic, assign) BOOL onlyDisplayText;

/** 多行文字同时轮播显示,仅文字轮播有效 */
@property (nonatomic, assign) NSUInteger lineCount;

/** pagecontrol 样式,默认为动画样式 */
@property (nonatomic, assign) SDCycleScrollViewPageContolStyle pageControlStyle;

Expand Down
12 changes: 11 additions & 1 deletion SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions SDCycleScrollView/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down