Skip to content

UIButton.setBackgroundColor

S025_신명섭 edited this page Dec 1, 2021 · 1 revision

형태

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)
}

Booster🚀🔥

Info

Rule

Backlog

공통 모듈

구현 설명 및 기능 정리

Architecture

Architecture

회의록 & DailyScrum & 회고록

멘토링 피드백

멘토링 피드백
Clone this wiki locally