V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
liaojinxing
V2EX  ›  iDev

分享 iOS 自动循环轮播组件

  •  
  •   liaojinxing · 2015-10-14 20:04:06 +08:00 · 2662 次点击
    这是一个创建于 3335 天前的主题,其中的信息可能已经有所发展或是发生改变。

    可实现自动循环轮播 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.

    2 条回复    2015-10-19 20:36:39 +08:00
    Ixizi
        1
    Ixizi  
       2015-10-18 16:19:22 +08:00
    看不懂,你就不能上个 GIF 图片吗
    strom001
        2
    strom001  
       2015-10-19 20:36:39 +08:00
    点开就有了啊
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   974 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 20:25 · PVG 04:25 · LAX 12:25 · JFK 15:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.