可实现自动循环轮播 slider 效果
源码和使用 demo 都在这里:
https://github.com/liaojinxing/LJAutoScrollView欢迎使用,如有问题也请不吝赐教。
LJAutoScrollView
=================
LJAutoScrollView class provides an endlessly circulate scroll view. It allows auto scrolling infinitely in the horizontal direction.
- It offers an encapsulation of UICollectionView to support reuse features.
- Use NSTimer for auto scrolling.
- The implement of infinite scroll is inspired by this page:[Circular Infinite UIScrollView]
Comparison
-----------
Compared to other implmentation, LJAutoScrollView is more stable and easier to use:
- Some implementation like [GBInfiniteScrollView] is subclass from UIScrollView, while LJAutoScrollView uses UICollectionView, it's more stable on reuse feature and gesture recognization.
- LJAutoScrollView integrates UIPageControl as well. You need not to handle the page change yourself.
- The infinite circulate scroll feature implementation is more elegant and robust than [SDCycleScrollView].
- It's easier to use. The usage is described below.
Installation
----------
Grab the source file into your project.
Or use cocoapods. Here is an example of your podfile:
```
pod 'LJAutoScrollView'
```
Usage
------
- LJAutoScrollView is a subclass of UIView. Just take it as UIView when initialization.
```
self.autoScrollView = [[LJAutoScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, kAutoScrollViewHeight)];
self.autoScrollView.delegate = self;
```
- Configure it as you like.
```
self.autoScrollView.itemSize = CGSizeMake(self.view.frame.size.width, kAutoScrollViewHeight);
self.autoScrollView.scrollInterval = 3.0f;
```
- Don't forget to implement the delegate methods.
Check the demo project for more details.
[Circular Infinite UIScrollView]:
http://iosdevelopertips.com/user-interface/creating-circular-and-infinite-uiscrollviews.html[GBInfiniteScrollView]:
https://github.com/gblancogarcia/GBInfiniteScrollView[SDCycleScrollView]:
https://github.com/gsdios/SDCycleScrollView
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/228059
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.