【发布时间】:2016-09-12 16:01:01
【问题描述】:
我正在使用 drawRect 绘制一个非常简单的形状(下图中为深蓝色)。
我希望这个动画从左到右,以便它增长。这里需要注意的是,我需要有一个灰色的“最大”背景,如图像的顶部所示。
现在,我通过覆盖一个白色视图来模拟这个动画,然后设置它的大小,这样看起来蓝色的动画就在右边。虽然这有效......我需要背景灰色形状始终存在。使用我的叠加白色视图,这不起作用。
这是绘制“当前代码”版本的代码:
let context = UIGraphicsGetCurrentContext()
CGContextMoveToPoint(context, 0, self.bounds.height - 6)
CGContextAddLineToPoint(context, self.bounds.width, 0)
CGContextAddLineToPoint(context, self.bounds.width, self.bounds.height)
CGContextAddLineToPoint(context, 0, self.bounds.height)
CGContextSetFillColorWithColor(context,UIColor(red: 37/255, green: 88/255, blue: 120/255, alpha: 1.0).CGColor)
CGContextDrawPath(context, CGPathDrawingMode.Fill)
如何使蓝色部分从左到右设置动画,同时保持图形的灰色“最大”部分始终可见?
【问题讨论】:
标签: ios swift animation drawrect cgcontextdrawpath