當設定了uiview的backgroundcolor,再去動畫改變uilabel的背景色會失敗
效果是 uilabel的背景色一點也沒改變。。//設定背景色
label.backgroundcolor = [uicolor redcolor];
...//動畫修改背景色
cabasicanimation* cocoranimation = [cabasicanimation animationwithkeypath:@"backgroundcolor"];
cgcolorref origincolor = [uicolor whitecolor].cgcolor;
cgcolorref darkgray = [uicolor bluecolor].cgcolor;
cocoranimation.fromvalue = (__bridge id)origincolor;
cocoranimation.tovalue = (__bridge id)darkgray;
cocoranimation.duration = 0.8;
[self.label.layer addanimation:cocoranimation forkey:@""];
修改使用layer的backgroundcolor
這次動畫成功了。//設定背景色
label.layer.backgroundcolor = [uicolor redcolor].cgcolor;
...//動畫修改背景色
cabasicanimation* cocoranimation = [cabasicanimation animationwithkeypath:@"backgroundcolor"];
cgcolorref origincolor = [uicolor whitecolor].cgcolor;
cgcolorref darkgray = [uicolor bluecolor].cgcolor;
cocoranimation.fromvalue = (__bridge id)origincolor;
cocoranimation.tovalue = (__bridge id)darkgray;
cocoranimation.duration = 0.8;
[self.label.layer addanimation:cocoranimation forkey:@""];
參考鏈結:how-to-animate-the-background-color-of-a-uilabel
高逼格UILabel的閃爍動畫效果
高逼格uilabel的閃爍動畫效果 最終效果圖如下 原始碼 yxlabel.h 與 yxlabel.m created by youxianming on 14 8 23.import inte ce yxlabel uiview property nonatomic,strong nsstring...
高逼格UILabel的閃爍動畫效果
高逼格uilabel的閃爍動畫效果 最終效果圖如下 原始碼 yxlabel.h 與 yxlabel.m yxlabel.h created by youxianming on 14 8 23.import inte ce yxlabel uiview property nonatomic,stron...
動畫的使用
1.使用uiview類函式實現 uiview beginanimations animationid context nil uiview setanimationduration 0.5f uiview setanimationcurve uiviewanimationcurveeaseinout...