調色大師 — 彼得潘deeplove
阿新 • • 發佈:2018-12-23
程式碼:
Slider
@IBAction func redSliderChanged(_ sender: Any) {
imageView.backgroundColor = UIColor(red: CGFloat(redSliderValue.value), green: CGFloat(greenSliderValue.value), blue: CGFloat(blueSliderValue.value), alpha: CGFloat(alphaSliderValue.value))
redLabel.text = String(Int(redSliderValue.value*255))
}
@IBAction func greenSliderChanged(_ sender: Any) {
imageView.backgroundColor = UIColor(red: CGFloat(redSliderValue.value), green: CGFloat(greenSliderValue.value), blue: CGFloat(blueSliderValue.value), alpha: CGFloat(alphaSliderValue.value))
greenLabel.text = String(Int(greenSliderValue.value*255))
}
@IBAction func blueSliderChanged(_ sender: Any) {
imageView.backgroundColor = UIColor(red: CGFloat(redSliderValue.value), green: CGFloat(greenSliderValue.value), blue: CGFloat(blueSliderValue.value), alpha: CGFloat(alphaSliderValue.value))
blueLabel.text = String(Int(blueSliderValue.value*255))
}
@IBAction func alphaSliderChanged(_ sender: Any) {
imageView.backgroundColor = UIColor(red: CGFloat(redSliderValue.value), green: CGFloat(greenSliderValue.value), blue: CGFloat(blueSliderValue.value), alpha: CGFloat(alphaSliderValue.value))
alphaLabel.text = String(format: “%.2f”, alphaSliderValue.value)
}
圓角
@IBAction func cornerSliderChanged(_ sender: Any) {
imageView.layer.cornerRadius = CGFloat(cornerSliderValue.value)
cornerLabel.text = String(Int(cornerSliderValue.value))
}