[UIView animateWithDuration:3.0 animations:^{
gradient = CGGradientCreateWithColorComponents(colorSpace, colors, locations, number_of_locations);
CGContextDrawRadialGradient(context, gradient, start, 0, end, sqrt((self.frame.size.width*self.frame.size.width)+(self.frame.size.height*self.frame.size.height)), kCGGradientDrawsBeforeStartLocation);
}];
大多数情况下都有效。每次我改变颜色时,它都会以完全相反的颜色闪烁。例如,当它要从橙色变成橙色时,它会以绿色闪烁。 社区,如何解决? :D
谢谢。
答案 0 :(得分:1)
请改用CAGradientLayer。 colors
属性是可动画的。
你上面使用的代码没有改变任何可动画的属性,并且在上下文中有点缺乏(双关语)所以我不确定它是如何“工作”的 - 它看起来不像一个有效的动画块。