내 응용 프로그램에서 나는 아래 그림과 같이 API에서 얻는 50 %, 80 %와 같은 백분율 값을 사용하여 붉은 색 원을 채울 필요가있는 요구 사항을 가지고 있습니다.원색을 백분율 값으로 채우는 방법은 무엇입니까?
현재 나는 이것을 달성하기 위해 아래의 코드를 사용하고 있습니다.
let roundView = UIView(frame:CGRect(x: 100, y: 100, width: 250, height: 250))
roundView.backgroundColor = UIColor.white
roundView.layer.cornerRadius = roundView.frame.size.width/2
// bezier path
let circlePath = UIBezierPath(arcCenter: CGPoint (x: roundView.frame.size.width/2, y: roundView.frame.size.height/2),
radius: roundView.frame.size.width/2,
startAngle:CGFloat(M_PI_2),
endAngle: CGFloat (M_PI * 2.0),
clockwise: true)
circlePath.move(to: roundView.center)
// circle shape
let circleShape = CAShapeLayer()
circleShape.path = circlePath.cgPath
circleShape.strokeColor = UIColor.black.cgColor
circleShape.fillColor = UIColor.green.cgColor
circleShape.lineWidth = 1.5
// add sublayer
roundView.layer.addSublayer(circleShape)
// add subview
self.view.addSubview(roundView)*
당신이 어떻게이 작업을 수행하는 날을 제안 해주십시오 수
아래처럼 보이고있다. 현재 나는 퍼센트로 변환하는 문제에 직면하고있다.
당신은 사용할 수 있습니다 https://github.com/xyfeng/XYPieChart – raki
이이 할 수있는 좋은 컨트롤입니다 : https://github.com/yasuoza/XYDoughnutChart – bisma
라키 (Raki)와 비스 마 감사합니다 빠른 응답을 위해 제 3 자 라이브러리를 사용하고 싶지 않습니다. – lazyCoder