Skip to content

New features of customizing the iOS14 PageControl control

License

Notifications You must be signed in to change notification settings

zeqinjie/ZQEndlessPageControl

Repository files navigation

ZQEndlessPageControl

CI Status Version License Platform

功能

自定义 iOS14 PageControl 控件新功能 ☑️

  • 最大展示个数 ☑️
  • 设置大小、间隙、背景颜色 ☑️
  • 设置边框大小,颜色 ☑️
  • 设置大、中、小,三种状态的缩放系数 ☑️
  • 设置背景图 ☑️

效果

使用

配置对象

public struct ZQEndlessPageControlConfiguration {
    /// 总共点个数
    var numberOfDots: Int
    /// 支持最大展示多少个点
    var maxNumberOfDots: ZQEndlessPageControlMaxNumberOfDots
    /// 选择点的颜色
    var selectedDotColor: UIColor
    /// 未选择点的颜色
    var unselectedDotColor: UIColor
    /// 点大小
    var dotSize: CGFloat
    /// 点间隙
    var spacing: CGFloat
    /// 未选中的缩放系数
    var mediumScale: CGFloat
    /// 选中的缩放系数
    var selectedScale: CGFloat
    /// 最小的点的缩放系数
    var smallScale: CGFloat
    /// 点边框色
    var dotBorderColor: UIColor?
    /* 📢注意当设置了 selectedIndicatorImage & unselectedIndicatorImage 时候,不展示默认的圆点*/
    /// 当前选中展示图片
    var selectedIndicatorImage: UIImage?
    /// 当前未选中展示图片
    var unselectedIndicatorImage: UIImage?
}

DEMO

import ZQEndlessPageControl

fileprivate let indicatorPageControl1: ZQEndlessPageControlIndicator = ZQEndlessPageControlIndicator()
self.view.addSubview(indicatorPageControl1)
indicatorPageControl1.snp.makeConstraints { (make) in
    make.center.equalToSuperview()
}
    
let indicatorConfigure = ZQEndlessPageControlConfiguration(
    numberOfDots: Metric.indicatorPageDotNum,
    dotSize: 8,
    dotBorderColor: UIColor.black.withAlphaComponent(0.19)
)
indicatorPageControl1.setup(configuration: indicatorConfigure)

// 设置指示图的图标
if #available(iOS 13.0, *) {
    self.view.addSubview(indicatorPageControl3)
    indicatorPageControl3.snp.makeConstraints { (make) in
        make.centerX.equalToSuperview()
        make.top.equalTo(self.indicatorPageControl2.snp.bottom).offset(10)
    }
    
    
    let indicatorConfigure = ZQEndlessPageControlConfiguration(
        numberOfDots: Metric.indicatorPageDotNum,
        maxNumberOfDots: .seven,
        dotSize: 20,
        selectedIndicatorImage: UIImage(systemName: "sun.max.fill"),
        unselectedIndicatorImage: UIImage(systemName: "moon.fill")
    )
    
   indicatorPageControl3.setup(configuration: indicatorConfigure)
}

安装

ZQEndlessPageControl is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ZQEndlessPageControl'

Author

zhengzeqin, [email protected]

License

ZQEndlessPageControl is available under the MIT license. See the LICENSE file for more info.

About

New features of customizing the iOS14 PageControl control

Resources

License

Stars

Watchers

Forks

Packages

No packages published