Level : WORDPRESS BOOK LINKEDIN PATENT Send Mail 동냥하기 hajunho.com

반응형

class FilledRect : UIView {

    

    init(frame: CGRect, level: CGFloat, color: UIColor) {

        //        super.init(frame: frame)

        super.init(frame: CGRect(x: 0, y: 0, width: 1, height: 0)) //TODO: HAVE

        self.layer.borderWidth = 1.0

        let levelLayer = CAShapeLayer()

        levelLayer.path = UIBezierPath(roundedRect: CGRect(x: frame.origin.x,

                                                           y: frame.origin.y,

                                                           width: frame.width * level,

                                                           height: frame.height),

                                       cornerRadius: 0).cgPath

        levelLayer.fillColor = color.cgColor

        self.layer.addSublayer(levelLayer)

    }

    

    required init?(coder aDecoder: NSCoder) {

        fatalError("Required, but Will not be called in a Playground")

    }

}


이런거 쓸 때,


좌표를 더해서 붙여줘야 한다.


이런 식으로...

        var view1 : UIView = FilledRect(frame: CGRect(x: 0, y: 0, width: 10, height: CGFloat(ph*ratio)), level: 1, color :  colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1))

        var view2 : UIView = FilledRect(frame: CGRect(x: 0, y: 0, width: 10, height: CGFloat(ph*ratio) + CGFloat(pn*ratio)), level: 1, color :  colorLiteral(red: 0.1764705926, green: 0.01176470611, blue: 0.5607843399, alpha: 1))

        var view3 : UIView = FilledRect(frame: CGRect(x: 0, y: 0, width: 10, height: CGFloat(pl*ratio) + CGFloat(ph*ratio) + CGFloat(pn*ratio)), level: 1, color :  colorLiteral(red: 0.521568656, green: 0.1098039225, blue: 0.05098039284, alpha: 1))


이 딴거 안통함.

   imgView1.addSubview(imgBasal)

        imgView1.snp.makeConstraints{

            $0.left.equalToSuperview()

            $0.top.equalToSuperview()

        }

        

        imgView11.addSubview(imgBasal1)

        imgView11.snp.makeConstraints{

            $0.left.equalToSuperview()

            $0.top.equalTo(imgView1.snp.bottom)

        }

        


반응형
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기