如何找出任何UIColor SWift [重复]的十六进制值>> [

问题描述 投票:0回答:1

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){//将背景色设置为...

ios swift iphone xcode uicolor
1个回答
0
投票
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
© www.soinside.com 2019 - 2024. All rights reserved.