bezierpath (삼각형 모양)를 UIView 컨테이너 내부에 추가하려고합니다. 그러나 UIView 컨테이너의 포인트를 올바르게 가져 오는 것 같습니다.bezierpath를 UIView 컨테이너 안에 추가합니다.
내가 같은 출력을 싶습니다 : 나는 (여기서 삼각형의 스트립은 컨테이너보기의 왼쪽에 표시되는 것) 결과이 무엇입니까 당신은 분명히 뷰 컨트롤러의 viewDidLoad
에이 코드를하고있는
// adding container to add image
self.topContainer.backgroundColor = UIColor(red: 49/255, green: 207/255, blue: 203/255, alpha: 1)
// self.topContainer.backgroundColor = UIColor.white
self.topContainer.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(self.topContainer)
self.topContainer.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
self.topContainer.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.55).isActive = true
self.topContainer.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
let bezierPath = UIBezierPath()
bezierPath.move(to: CGPoint(x: 0, y: self.topContainer.frame.size.height))
bezierPath.addLine(to: CGPoint(x: self.topContainer.frame.size.width, y: 222))
bezierPath.addLine(to: CGPoint(x: self.topContainer.frame.size.width, y: self.topContainer.frame.size.height))
bezierPath.addLine(to: CGPoint(x: 0, y: self.topContainer.frame.size.height))
UIColor.white.setFill()
bezierPath.fill()
bezierPath.lineWidth = 1
bezierPath.close()
let shapeLayer = CAShapeLayer()
shapeLayer.path = bezierPath.cgPath
shapeLayer.lineWidth = 2.0
shapeLayer.strokeColor = UIColor.white.cgColor
shapeLayer.fillColor = UIColor.white.cgColor
self.topContainer.layer.addSublayer(shapeLayer)
?? 첫 번째 스크린 샷에는 파란색이나 빨간색이 표시되지 않습니다. – matt
setFill은 UIColor.white.setFill()이어야하므로 실제 UIView 컨테이너의 초록색 위에 흰색 삼각형이 있어야합니다. 비록 내가 내 라인 연결이 정확하다고 생각하더라도 그것의 표시 안돼 ?? @matt – Aboogie
"녹색 삼각형 위에 흰색 삼각형이 있어야합니다."그런 다음 푸른 색 위에 빨간색 삼각형을 표시하는 것은 매우 어리 석습니다! – matt