Git Product home page Git Product logo

fwcyclescrollview's Introduction

IOS之轮播控件 -- OC/Swift4.0

Platform  Language  License

支持pod导入:

pod 'FWCycleScrollView'
注意:如出现 Unable to find a specification for 'FWCycleScrollView' 错误,可执行 pod repo update 命令。

可设置参数:

/// 本地图片
@objc public var localizationImageNameArray: [String]?
/// 网络图片
@objc public var imageUrlStrArray: [String]?
/// 预加载图片
@objc public var placeholderImage: UIImage?
/// 自定义UI等
@objc public var viewArray: [UIView]?

/// 是否自动轮播
@objc public var autoScroll = true
/// 自动轮播间隔时间
@objc public var autoScrollTimeInterval: TimeInterval = 5.0

/// 轮播图滚动方向
@objc public var scrollDirection: UICollectionViewScrollDirection = .horizontal
/// 轮播轮回次数(1个轮回指的是1组UI轮播完成)
@objc public var loopTimes = 100
/// 选中分页控件的颜色
@objc public var currentPageDotColor = UIColor.white
/// 未选中分页控件的颜色
@objc public var pageDotColor = UIColor.lightGray
/// 分页控件类型
@objc public var pageControlType: PageControlType = .classic
/// 自定义分页控件类型
@objc public var customDotViewType: FWCustomDotViewType = .hollow
/// 分页控件位置
@objc public var pageControlAliment: PageControlAliment = .center
/// 分页控件Insets值
@objc public var pageControlInsets: UIEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0)
/// 分页控件默认距离的边距
@objc public var pageControlMargin: CGFloat = 10

/// 分页控件大小,注意:当PageControlType不等于自定义类型时,只能影响当前分页控件的大小,不能影响分页控件原点的大小
@objc public var pageControlDotSize: CGSize = CGSize(width: 10, height: 10)
/// 自定义分页控件,选中分页控件放大的倍数
@objc public var currentPageDotEnlargeTimes: CGFloat = 0.0

/// 某一项滚动回调
@objc public var itemDidScrollBlock: ItemDidScrollBlock?
/// 某一项点击回调
@objc public var itemDidClickedBlock: ItemDidClickedBlock?

简单使用:(注:可下载demo具体查看,分别有OC、Swift的demo)

/// 类初始化方法
///
/// - Parameter frame: FWCycleScrollView的大小
/// - Returns: self
@objc open class func cycleImage(frame: CGRect) -> FWCycleScrollView

OC:

NSArray *netAdArray = @[@"http://pic2.16pic.com/00/10/46/16pic_1046407_b.jpg",
                        @"http://pic.58pic.com/58pic/14/34/62/39S58PIC9jV_1024.jpg",
                        @"http://pic.qiantucdn.com/58pic/17/70/72/02U58PICKVg_1024.jpg",
                        @"http://pic.58pic.com/58pic/16/73/95/63E58PICQh7_1024.jpg"];
[FWCycleScrollView cycleImageWithImageUrlStrArray: netAdArray
                                 placeholderImage: [UIImage imageNamed:@"ad_placeholder"]
                                            frame: CGRectMake(0, 0, self.view.frame.size.width, 100)];

Swift:

let netAdArray = ["http://pic2.16pic.com/00/10/46/16pic_1046407_b.jpg",
                  "http://pic.58pic.com/58pic/14/34/62/39S58PIC9jV_1024.jpg",
                  "http://pic.qiantucdn.com/58pic/17/70/72/02U58PICKVg_1024.jpg",
                  "http://pic.58pic.com/58pic/16/73/95/63E58PICQh7_1024.jpg"]
FWCycleScrollView.cycleImage(imageUrlStrArray: netAdArray,
                             placeholderImage: UIImage(named: "ad_placeholder"),
                                        frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 100))

效果:

结尾语:

  • 使用过程中有任何问题或者新的需求都可以issues我哦;
  • 欢迎关注本人更多的UI库,谢谢;

fwcyclescrollview's People

Contributors

choiceyou avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.