Simple UITableViewCell effects fly in and out of some of the recently released controls, some of which are about UITableViewCell display.
A friend asked me how to do it. I wrote a simple introduction.
1. UITableView need to implement-(void) TableView: (UITableView *) TableView Willdisplaycell: (Testtableviewcell *) cell Forrowatindexpath: (Nsindexpath *) Indexpath
-(void) TableView: (UITableView *) TableView Willdisplaycell: (Testtableviewcell *) cell Forrowatindexpath: (Nsindexpath *) Indexpath {[cell animationforindexpath:indexpath];}
2. UITableViewCell need to implement-(void) Animationforindexpath: (Nsindexpath *) Indexpath
-(void) Animationforindexpath: (Nsindexpath *) Indexpath { int row = indexpath.row; float radians = (+ row*30)%360; radians = 20; calayer * layer = [[Self.layer sublayers] objectatindex:0]; //Rotation animation cabasicanimation *animation = [cabasicanimation animationwithkeypath:@ "transform.rotation"]; animation.fromvalue [Email protected]_to_radians (RADIANS); Animation.tovalue = @DEGREES_TO_RADIANS (0); //Opacity animation; cabasicanimation *fadeanimation = [cabasicanimation animationwithkeypath:@ "opacity"]; fadeanimation.fromvalue = @0.1f; fadeanimation.tovalue = @1.f; //translation Animation cabasicanImation *translationanimation = [cabasicanimation animationwithkeypath:@ "transform.translation.x"]; ; translationanimation.fromvalue = @ ( -300.F * ((indexpath.row%2 = = 0)? -1:1)); translationanimation.tovalue = @0.f; caanimationgroup *animationgroup = [Caanimationgroup animation]; Animationgroup.duration = 0.4f; animationgroup.animations = @[animation,fadeAnimation, Translationanimation]; animationgroup.timingfunction = [CAMediaTimingFunction Functionwithname:kcamediatimingfunctioneaseineaseout]; [layer addAnimation: Animationgroup forkey:@ "Spinanimation"];}
3. The corresponding macro
#define Degrees_to_radians (d) (d * m_pi/180)
TableView Slide-out animation