BannerView

@MainActor
open class BannerView : UIView, UICollectionViewDataSource, UICollectionViewDelegate

Banner视图

SDCycleScrollView

Track

  • Undocumented

    Declaration

    Swift

    @_spi(FW)
    public nonisolated static var trackClickBlock: (@MainActor @Sendable (UIView, IndexPath?) -> Bool)? { get set }
  • Undocumented

    Declaration

    Swift

    @_spi(FW)
    public nonisolated static var trackExposureBlock: (@MainActor @Sendable (UIView) -> Void)? { get set }

Accessor

  • 图片数组,支持String|URL|UIImage

    Declaration

    Swift

    @MainActor
    open var imagesGroup: [Any]? { get set }
  • 每张图片对应要显示的文字数组

    Declaration

    Swift

    @MainActor
    open var titlesGroup: [Any]? { get set }
  • 自动滚动间隔时间,默认2s

    Declaration

    Swift

    @MainActor
    open var autoScrollTimeInterval: TimeInterval { get set }
  • 是否无限循环,默认true

    Declaration

    Swift

    @MainActor
    open var infiniteLoop: Bool { get set }
  • 是否自动滚动,默认true

    Declaration

    Swift

    @MainActor
    open var autoScroll: Bool { get set }
  • 图片滚动方向,默认为水平滚动

    Declaration

    Swift

    @MainActor
    open var scrollDirection: UICollectionView.ScrollDirection { get set }
  • 是否启用根据item分页滚动,默认false,根据frame大小滚动

    Declaration

    Swift

    @MainActor
    open var itemPagingEnabled: Bool { get set }
  • 整体布局尺寸,默认0占满视图,itemPagingEnabled启用后生效

    Declaration

    Swift

    @MainActor
    open var itemSize: CGSize { get set }
  • 整体布局间隔,默认0,itemPagingEnabled启用后生效

    Declaration

    Swift

    @MainActor
    open var itemSpacing: CGFloat { get set }
  • 是否设置item分页停留位置居中,默认false,停留左侧,itemPagingEnabled启用后生效

    Declaration

    Swift

    @MainActor
    open var itemPagingCenter: Bool { get set }
  • 事件代理

    Declaration

    Swift

    @MainActor
    open weak var delegate: BannerViewDelegate? { get set }
  • 句柄方式监听点击,参数为index

    Declaration

    Swift

    @MainActor
    open var didSelectItemBlock: ((Int) -> Void)?
  • 句柄方式监听滚动,快速滚动时也会回调,参数为index

    Declaration

    Swift

    @MainActor
    open var didScrollToItemBlock: ((Int) -> Void)?
  • 自定义cell句柄,参数为cell和index

    Declaration

    Swift

    @MainActor
    open var customCellBlock: ((UICollectionViewCell, Int) -> Void)?
  • 轮播图片的ContentMode,默认为scaleAspectFill

    Declaration

    Swift

    @MainActor
    open var imageViewContentMode: UIView.ContentMode
  • 占位图,用于网络未加载到图片时

    Declaration

    Swift

    @MainActor
    open var placeholderImage: UIImage?
  • 是否显示分页控件

    Declaration

    Swift

    @MainActor
    open var showsPageControl: Bool { get set }
  • 自定义pageControl控件,初始化后调用

    Declaration

    Swift

    @MainActor
    open var customPageControl: ((UIControl) -> Void)?
  • 是否在只有一张图时隐藏pagecontrol,默认为true

    Declaration

    Swift

    @MainActor
    open var hidesForSinglePage: Bool
  • 只展示文字轮播

    Declaration

    Swift

    @MainActor
    open var onlyDisplayText: Bool
  • pageControl 样式,默认为系统样式

    Declaration

    Swift

    @MainActor
    open var pageControlStyle: BannerViewPageControlStyle
  • 分页控件位置

    Declaration

    Swift

    @MainActor
    open var pageControlAlignment: BannerViewPageControlAlignment
  • 分页控件距离轮播图的底部间距(在默认间距基础上)的偏移量

    Declaration

    Swift

    @MainActor
    open var pageControlBottomOffset: CGFloat
  • 分页控件距离轮播图的右边间距(在默认间距基础上)的偏移量

    Declaration

    Swift

    @MainActor
    open var pageControlRightOffset: CGFloat
  • 分页控件小圆标大小

    Declaration

    Swift

    @MainActor
    open var pageControlDotSize: CGSize { get set }
  • 分页控件当前小圆标大小,默认zero同pageControlDotSize

    Declaration

    Swift

    @MainActor
    open var pageControlCurrentDotSize: CGSize { get set }
  • 分页控件小圆标间隔

    Declaration

    Swift

    @MainActor
    open var pageControlDotSpacing: CGFloat { get set }
  • 当前分页控件小圆标颜色

    Declaration

    Swift

    @MainActor
    open var currentPageDotColor: UIColor? { get set }
  • 其他分页控件小圆标颜色

    Declaration

    Swift

    @MainActor
    open var pageDotColor: UIColor? { get set }
  • 当前分页控件小圆标图片

    Declaration

    Swift

    @MainActor
    open var currentPageDotImage: UIImage? { get set }
  • 其他分页控件小圆标图片

    Declaration

    Swift

    @MainActor
    open var pageDotImage: UIImage? { get set }
  • 分页控件自定义视图类,默认为DotView

    Declaration

    Swift

    @MainActor
    open var pageDotViewClass: (UIView & DotViewProtocol).Type? { get set }
  • 轮播文字label字体颜色

    Declaration

    Swift

    @MainActor
    open var titleLabelTextColor: UIColor?
  • 轮播文字label字体

    Declaration

    Swift

    @MainActor
    open var titleLabelTextFont: UIFont?
  • 轮播文字label背景颜色

    Declaration

    Swift

    @MainActor
    open var titleLabelBackgroundColor: UIColor?
  • 轮播文字label高度

    Declaration

    Swift

    @MainActor
    open var titleLabelHeight: CGFloat
  • 轮播文字间距设置(影响背景),默认全部0

    Declaration

    Swift

    @MainActor
    open var titleLabelInset: UIEdgeInsets
  • 轮播文字内容间距设置(不影响背景),默认{0 16 0 16}

    Declaration

    Swift

    @MainActor
    open var titleLabelContentInset: UIEdgeInsets
  • 轮播文字label对齐方式

    Declaration

    Swift

    @MainActor
    open var titleLabelTextAlignment: NSTextAlignment
  • 图片视图间距设置,默认全部0

    Declaration

    Swift

    @MainActor
    open var imageViewInset: UIEdgeInsets
  • 内容视图间距设置,默认全部0

    Declaration

    Swift

    @MainActor
    open var contentViewInset: UIEdgeInsets
  • 内容视图圆角设置,默认0

    Declaration

    Swift

    @MainActor
    open var contentViewCornerRadius: CGFloat
  • 内容视图背景色,默认nil

    Declaration

    Swift

    @MainActor
    open var contentViewBackgroundColor: UIColor?
  • 当前index,默认-1

    Declaration

    Swift

    @MainActor
    open private(set) var currentIndex: Int { get }

Subviews

  • Undocumented

    Declaration

    Swift

    @MainActor
    open private(set) lazy var mainView: UICollectionView { get set }
  • Undocumented

    Declaration

    Swift

    @MainActor
    open private(set) lazy var flowLayout: BannerViewFlowLayout { get set }
  • Undocumented

    Declaration

    Swift

    @MainActor
    open private(set) weak var pageControl: UIControl? { get }

Lifecycle

  • Undocumented

    Declaration

    Swift

    @MainActor
    override public init(frame: CGRect)
  • Undocumented

    Declaration

    Swift

    @MainActor
    public required init?(coder: NSCoder)
  • Undocumented

    Declaration

    Swift

    @MainActor
    override open func layoutSubviews()
  • Undocumented

    Declaration

    Swift

    @MainActor
    override open func willMove(toSuperview newSuperview: UIView?)

UICollectionView

Public

  • 手工滚动到指定index,可指定动画

    Declaration

    Swift

    @MainActor
    open func scrollToIndex(_ index: Int, animated: Bool = false)
  • 滚动手势禁用(文字轮播较实用)

    Declaration

    Swift

    @MainActor
    open func disableScrollGesture()
  • 解决viewWillAppear时出现时轮播图卡在一半的问题,在控制器viewWillAppear时调用此方法

    Declaration

    Swift

    @MainActor
    open func adjustWhenViewWillAppear()
  • Undocumented

    Declaration

    Swift

    @_spi(FW)
    @MainActor
    public func pageControlIndex(cellIndex index: Int) -> Int

BannerView+StatisticalView