func HSBColorColorPickerTouched(sender:HSBColorPicker, color:UIColor, point:CGPoint, state:UIGestureRecognizerState){
// Set the background color to the selected
//self.view.backgroundColor = color
self.dismiss(animated: true) {
print("Color", color)
}
// Set the color of the buttons accordingly
// Remove the view if it shares the tag
if let view = self.view.viewWithTag(colorPickerViewTag){
view.removeFromSuperview()
}
}
我不知道如何在十六进制字符串中获取UIcolor值
//添加HSBColorPicker委托函数func HSBColorColorPickerTouched(sender:HSBColorPicker,color:UIColor,point:CGPoint,state:UIGestureRecognizerState){//将背景色设置为...
func hexStringFromColor(color: UIColor) -> String {
let components = color.cgColor.components
let r: CGFloat = components?[0] ?? 0.0
let g: CGFloat = components?[1] ?? 0.0
let b: CGFloat = components?[2] ?? 0.0
let hexString = String.init(format: "#%02lX%02lX%02lX", lroundf(Float(r * 255)), lroundf(Float(g * 255)), lroundf(Float(b * 255)))
print(hexString)
return hexString