We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
setBackgroundColor(color: UIColor, for state: UIControl.State)
UIButton의 상태에 따라 backgroundColor를 변경합니다.
func setBackgroundColor(color: UIColor, for state: UIControl.State) { UIGraphicsBeginImageContext(CGSize(width: 1.0, height: 1.0)) guard let context = UIGraphicsGetCurrentContext() else { return } context.setFillColor(color.cgColor) context.fill(CGRect(x: 0.0, y: 0.0, width: 1.0, height: 1.0)) let backgroundImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() self.setBackgroundImage(backgroundImage, for: state) }