MKColorPicker
##MKColorPicker MKColorPicker是一个非常优秀的颜色选择器
示例
要运行示例项目,首先克隆仓库,然后在Example目录中运行pod install
截图
要求
iOS8+
安装
MKColorPicker可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中
pod "MKColorPicker"
如何使用
import MKColorPicker
let MKColorPicker = MKColorPickerViewController()
MKColorPicker.selectedColor = { color in
//Put your code that will be excuted when select a color
}
//To inialize the picker as popover controller
if let popoverController = MKColorPicker.popoverPresentationController{
popoverController.delegate = MKColorPicker
popoverController.permittedArrowDirections = .any
popoverController.sourceView = sender
popoverController.sourceRect = sender.bounds
}
self.present(MKColorPicker, animated: true, completion: nil)
自定义选择器
MKColorPicker.autoDismissAfterSelection = false //default: true
MKColorPicker.scrollDirection = .vertical //default: .horizontal
MKColorPicker.style = .square //default: .circle
MKColorPicker.pickerSize = CGSize(width: newWidth, height: newHeight) //default 250, 250
//Change default colors list "colorPalette.plist" contains array of hexa. colors,
//you can simply change it to your colors or initialize your list from anywhere your want.
var colors = [UIColor]()
let path = Bundle.main.path(forResource: "colorPalette", ofType: "plist")
let pListArray = NSArray(contentsOfFile: path!)
if let colorPalettePlistFile = pListArray as? [String] {
for col in colorPalettePlistFile{
colors.append(UIColor(hex: col))
}
}
MKColorPicker.allColors = colors
作者
Moayad Al kouz, [email protected]
许可证
MKColorPicker采用MIT许可证。有关更多信息,请参阅LICENSE文件。