分享 iOS 自动循环轮播组件

2015-10-14 20:04:06 +08:00
 liaojinxing
可实现自动循环轮播 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
2655 次点击
所在节点    iDev
2 条回复
Ixizi
2015-10-18 16:19:22 +08:00
看不懂,你就不能上个 GIF 图片吗
strom001
2015-10-19 20:36:39 +08:00
点开就有了啊

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/228059

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX