测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最新发布 | 2016年11月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Mycose 维护。
要运行示例项目,克隆仓库,然后首先从 Example 目录中运行 pod install
。
CMPageControl 是一个与 UIPageControl 类似但支持水平/垂直显示且可定制的 UIControl。目前您可以自定义边框宽度、背景颜色、边框颜色以及在需要图像而不是基本视图时使用图像
// current index, will apply selected style if you set manually
@IBInspectable public var currentIndex : Int = 0
// when set will "setup" the views
@IBInspectable public var numberOfElements : Int = 0
// to selecte if round or square
@IBInspectable public var isRounded : Bool = true
// unselected image
@IBInspectable public var elementImage : UIImage?
// unselected background color
@IBInspectable public var elementBackgroundColor : UIColor = UIColor.gray
// unselected border color
@IBInspectable public var elementBorderColor : UIColor = UIColor.gray
// unselected border width
@IBInspectable public var elementBorderWidth : CGFloat = 1.0
// element cornerRadius
@IBInspectable public var elementCornerRadius : CGFloat = 5.0
// selected image
@IBInspectable public var elementSelectedImage : UIImage? {
// selected background color
@IBInspectable public var elementSelectedBackgroundColor : UIColor = UIColor.white
// selected border color
@IBInspectable public var elementSelectedBorderColor : UIColor = UIColor.white
// selected border width
@IBInspectable public var elementSelectedBorderWidth : CGFloat = 2.0
// element width and height
@IBInspectable public var elementWidth : CGFloat = 10.0
// if you want the view to be aligned vertically or horizontally
public var orientation : CMPageControlOrientation = .Horizontal
public var delegate : CMPageControlDelegate?
self.pageControl = CMPageControl(frame: CGRect(x: 0, y: 40, width: 40, height: 200))
self.pageControl?.numberOfElements = 5
self.pageControl?.elementImage = image
self.pageControl?.elementSelectedImage = selectedImage
self.pageControl?.elementBackgroundColor = UIColor.clear
self.pageControl?.elementWidth = 20.0
self.pageControl?.elementBorderWidth = 0.0
self.pageControl?.elementSelectedBorderWidth = 0.0
self.pageControl?.elementSelectedBackgroundColor = UIColor.clear
self.pageControl?.orientation = .Vertical
self.view.addSubview(self.pageControl!)
/!\ might disappear because the UIControl should do the same
// called when a view is clicked
func elementClicked(pageControl : CMPageControl, atIndex: Int)
// decide if the index should change after the click
func shouldChangeIndex(from : Int, to : Int) -> Bool
CMPageControl 可以通过 CocoaPods 获得。要安装它,只需在 Podfile 中添加以下行
pod "CMPageControl"
Clément Morissard,[email protected]
CMPageControl 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。