
UIControlsColorButton::setColor 함수의 파라미터는 UIColor 객체를 받습니다.
UIColor 객체는 UIColor의 생성자 메소드를 사용하여 생성할 수 있습니다.
예를 들어, UIColor 객체를 생성하여 setColor 함수에 전달하는 방법은 다음과 같습니다.
#hostingforum.kr
swift
let colorButton = UIControl()
colorButton.backgroundColor = UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
colorButton.setTitleColor(UIColor.white, for: UIControl.State.normal)
colorButton.setTitle("버튼", for: UIControl.State.normal)
colorButton.layer.cornerRadius = 10
colorButton.layer.borderWidth = 1
colorButton.layer.borderColor = UIColor.black.cgColor
colorButton.layer.masksToBounds = true
또한, UIColor 객체를 생성할 때 사용할 수 있는 다양한 생성자 메소드가 있습니다.
예를 들어, UIColor 객체를 생성하여 setColor 함수에 전달하는 방법은 다음과 같습니다.
#hostingforum.kr
swift
let colorButton = UIControl()
colorButton.backgroundColor = UIColor.systemRed
colorButton.setTitleColor(UIColor.systemBackground, for: UIControl.State.normal)
colorButton.setTitle("버튼", for: UIControl.State.normal)
colorButton.layer.cornerRadius = 10
colorButton.layer.borderWidth = 1
colorButton.layer.borderColor = UIColor.systemGray.cgColor
colorButton.layer.masksToBounds = true
또한, UIColor 객체를 생성할 때 사용할 수 있는 다양한 생성자 메소드가 있습니다.
예를 들어, UIColor 객체를 생성하여 setColor 함수에 전달하는 방법은 다음과 같습니다.
#hostingforum.kr
swift
let colorButton = UIControl()
colorButton.backgroundColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 0.5)
colorButton.setTitleColor(UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0), for: UIControl.State.normal)
colorButton.setTitle("버튼", for: UIControl.State.normal)
colorButton.layer.cornerRadius = 10
colorButton.layer.borderWidth = 1
colorButton.layer.borderColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0).cgColor
colorButton.layer.masksToBounds = true
이러한 방법을 사용하여 UIColor 객체를 생성하여 setColor 함수에 전달할 수 있습니다.
2025-05-23 02:04