var backgroundPanel = UIView()

        

        

        backgroundPanel.backgroundColor = UIColor(red: 33, green: 33, blue: 23, alpha: 1.0)

        

        self.viewArea.addSubview(backgroundPanel)


이런 애들이 반복되면


    lazy var backgroundPanel : [UIView] = {

        let sample = UIView()

        sample.backgroundColor =  colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)

        let ret : [UIView] = Array(repeating: sample, count: 3)

        return ret

    }()


        backgroundPanel[0].snp.makeConstraints {

            $0.width.equalTo(280)

            $0.height.equalTo(44)

            $0.top.equalToSuperview().offset(GS.s.tendency_3dots_popup_lbltxt_topMargin)

            $0.left.equalToSuperview().offset(GS.s.tendency_3dots_popup_label_leftMargin)

        }


       backgroundPanel[1].snp.makeConstraints {

            $0.width.equalTo(350)

            $0.height.equalTo(44)

            $0.top.equalTo(lblLowestCGM.snp.bottom).offset(GS.s.tendency_3dots_popup_lbltxt_topMargin)

            $0.left.equalToSuperview().offset(GS.s.tendency_3dots_popup_label_leftMargin)

        }


        backgroundPanel[2].snp.makeConstraints {

            $0.width.equalTo(300)

            $0.height.equalTo(44)

            $0.top.equalTo(lblAvgSG.snp.bottom).offset(GS.s.tendency_3dots_popup_lbltxt_topMargin)

            $0.left.equalToSuperview().offset(GS.s.tendency_3dots_popup_label_leftMargin)

        }



이렇게 만들어 보고 싶을 것이다. 그러나 sample 은 하나의 객체이므로 

        var sample1 = UIView()

        sample1.backgroundColor =  colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)

        var sample2 = UIView()

        sample2.backgroundColor =  colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)

        var sample3 = UIView()

        sample3.backgroundColor =  colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)

        let ret : [UIView] = [sample1, sample2, sample3]


와 같이 다른 객체로 넘겨 주어야 한다. 코드를 줄이면, 


        let ret : [UIView] = [UIView(), UIView(), UIView()]

        for men in ret {

            men.backgroundColor =  colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)

        }

겠지.






'{BE} Python 3.1x' 카테고리의 다른 글

core graphics는 snapkit이 먹지 않는다.  (0) 2019.03.20
계산 잘 못하는 애플 코리아  (0) 2019.03.18
아이튠즈 구독 해지하지  (0) 2019.03.15
맥에도 블루스크린이 있을까?  (0) 2019.03.13
I bought a charger  (0) 2019.02.03

+ Recent posts