이 예제을 RubyMotion으로 변환하려고하는데 'pie slices'도 화면에 표시되지 않습니다. 이 예제에서는 for 루프를 사용하지 않습니다. 파이의 두 조각 만 사용하기 때문입니다. 어떤 아이디어?RubyMotion 원형 차트 CALayer
chart = UIView.alloc.initWithFrame(CGRect.new([60, 100], [200, 200]))
chart.backgroundColor = UIColor.colorWithRed(0, green:0, blue:0, alpha:0.5)
chart.layer.cornerRadius = 100
@window.addSubview(chart)
green = 70.0
red = 30.0
red = red/100.0 * 2.0 * Math::PI
green = green/100 * 2.0 * Math::PI
start = 0.0
path = UIBezierPath.alloc.init
finish = start + red
sa = start - Math::PI/2.0
ea = finish - Math::PI/2.0
puts sa, ea
path.moveToPoint(CGPoint.new(100, 100))
path.addArcWithCenter(CGPoint.new(100, 100), radius:100, startAngle:sa, endAngle:ea, clockwise:true)
sl = CAShapeLayer.alloc.init
sl.fillColor = UIColor.redColor
sl.path = path.CGPath
chart.layer.addSublayer(sl)
start = finish
path = UIBezierPath.alloc.init
finish = start + green
sa = start - Math::PI/2.0
ea = finish - Math::PI/2.0
path.moveToPoint(CGPoint.new(100, 100))
path.addArcWithCenter(CGPoint.new(100, 100), radius:100, startAngle:sa, endAngle:ea, clockwise:true)
sl = CAShapeLayer.alloc.init
sl.fillColor = UIColor.greenColor
sl.path = path.CGPath
chart.layer.addSublayer(sl)
mask = UIView.alloc.initWithFrame(CGRect.new([0, 0], [196, 196]))
mask.layer.cornerRadius = 98
mask.center = CGPoint.new(100, 100)
mask.backgroundColor = UIColor.whiteColor
chart.addSubview(mask)
''이동하십시오 window.addSubview @ (차트) ''마지막 줄에 – ahmet
Unfortunat ely가 작동하지 않았다. –