我想为每件作品添加一种颜色。我补充说:
let colors = [
[54.0/255.0, 78.0/255.0 ,44.0/255.0 ],
[252.0/255.0, 178.0/255.0, 141.0/255.0 ],
[242.0/255.0, 44.0/255.0 ,173.0/255.0 ],
[239.0/255.0, 42.0/255.0 , 93.0/255.0 ],
[169.0/255.0, 145.0/255.0, 135.0/255.0],
[122.0/255.0, 228.0/255.0, 140.0/255.0],
[110.0/255.0, 134.0/255.0, 36.0/255.0,],
[32.0/255.0, 143.0/255.0, 55.0/255.0,],
[178.0/255.0, 78.0/255.0, 6.0/255.0,],
[39.0/255.0, 53.0/255.0, 27.0/255.0,],
[46.0/255.0, 122.0/255.0, 151.0/255.0,],
]
let points = [[270, 290],[300, 320],[330, 350],[0, 20],[30, 50],[60, 80],[90, 110],[120, 140],[150, 170],[180, 200],[210, 230],[240, 260]]
func drawSmallCircles(){
let index = 0
for oneArray in points {
let startAngleRadiant: CGFloat = degreesToRadians(Double(oneArray[0]))
let endAngleRadiant: CGFloat = degreesToRadians(Double(oneArray[1]))
let radius: CGFloat = 50.0
let path = UIBezierPath(arcCenter: CGPoint(x: CGFloat(100), y: CGFloat(100)),
radius: radius,
startAngle: startAngleRadiant,
endAngle: endAngleRadiant,
clockwise: true)
let color = UIColor(red: CGFloat(colors[index][0]), green: CGFloat(colors[index][1]), blue: CGFloat(colors[index][2]), alpha: CGFloat(1))
color.setStroke()
path.lineWidth = CGFloat(10)
path.stroke()
}
}
override func drawRect(rect: CGRect) {
self.opaque = false;
drawSmallCircles()
}
但最后一种颜色总是显示出来。
但是当我这样做时,我得到了htis错误:
/Main.storyboard:error:IB Designables:无法呈现WaitingCircleView的实例:渲染视图的时间超过200毫秒。您的绘图代码可能会遇到性能下降的问题。
答案 0 :(得分:2)
你可能打算
var index = 0
而且,在循环中:
index++