TableView Slide-out animation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.