0
我試圖改變我的UIImageView
的背景顏色與CABasicAnimation
刪除的動畫漸變CABasicAnimation
我做這些事情CABasicAnimation
,但我不會動畫褪色,但我不知道我是否刪除此事情。
這是我的代碼:
UIColor *fromColor = [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0];
UIColor *toColor = [UIColor colorWithRed:((float)((rgbValue2 & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue2 & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue2 & 0xFF))/255.0 alpha:1.0];
CABasicAnimation *colorAnimation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
colorAnimation.duration = timeInterval;
colorAnimation.fromValue = (id)fromColor.CGColor;
colorAnimation.toValue = (id)toColor.CGColor;
if (number == 1) {
colorAnimation.repeatCount = HUGE_VALF;
} if (number == 0) {
colorAnimation.repeatCount = 1;
}
[self.colorImage.layer addAnimation:colorAnimation forKey:@"backgroundColor"];}
我可以刪除的淡入淡出效果?
這不是完全清楚你想要什麼。你想讓圖層的背景顏色淡入淡出嗎? –
不褪色,我只想改變顏色 –
爲什麼不能只調用'[self.colorImage.Layer setBackgroundColor:myColor.CGColor];'? –