
UIControlsColorButton::onChange 메소드는 ColorButton의 변경 이벤트를 처리하는 메소드입니다. 이 메소드는 ColorButton의 색상이 변경될 때 호출됩니다.
이 메소드의 파라미터는 다음과 같습니다.
- sender: ColorButton 객체
- color: 변경된 색상
이 메소드는 반환값이 없습니다.
UIControlsColorButton::onChange 메소드를 사용하여 ColorButton의 변경 이벤트를 처리하는 예제 코드는 다음과 같습니다.
#hostingforum.kr
swift
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var colorButton: ColorButton!
override func viewDidLoad() {
super.viewDidLoad()
colorButton.onChange = { [weak self] sender, color in
print("ColorButton의 색상이 변경되었습니다. 변경된 색상: (color)")
}
}
}
위 코드에서 onChange 메소드는 ColorButton의 색상이 변경될 때 호출됩니다. 변경된 색상은 color 변수에 저장되어 있습니다.
2025-05-11 20:41