enum text {

        case content

        case label

    }


    func bssBarTextAttributer(_ label : UILabel, _ type : text) {

        switch type {

        case text.content:

            label.font = UIFont.init(name: "".font1B(), size: GV.s.ui_dashboard_bssBar_panel_fontSize)

            label.textColor = UIColor(red: 62, green: 62, blue: 62)

            label.textAlignment = .center


        case text.label:

            label.font = UIFont.init(name: "".font1(), size: GV.s.ui_dashboard_bssBar_panel_label_fontsize)

            label.textColor = UIColor(red: 128, green: 128, blue: 128)

            label.textAlignment = .center

        }

    }


이렇게 정의한 후


    lazy var sensorBS : UILabel = {

        let label : UILabel = UILabel()

        label.text = "---"

        bssBarTextAttributer(label, text.content)

        return label

    }()


    lazy var bloodSugar : UILabel = {

        let label : UILabel = UILabel()

        label.text = "---"

        bssBarTextAttributer(label, text.content)

        return label

    }()


    lazy var bolus : UILabel = {

        let label : UILabel = UILabel()

        label.text = "-.--"

        bssBarTextAttributer(label, text.content)

        return label

    }()


편하다. 후행 클로저 같은 솔루션도 있으나 snippet 이 안됨. 그리고 요걸 맞보면 못쓰지 ^^ 싱글톤에 넣어 전역에서 써주면 더욱 좋다.

'!A. Basics' 카테고리의 다른 글

헥사 코드로 컬러 설정하기  (0) 2019.01.12
master cell customizing : master detail view  (0) 2019.01.12
싱글톤은 최소 2개 이상  (0) 2019.01.12
Snapkit closure 이해  (0) 2019.01.07
JAVA C/C++ Objective-C Swift  (0) 2019.01.02

+ Recent posts