点击cell时动画效果

效果图:

工程图:

代码:

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
<UITableViewDataSource,UITableViewDelegate>
{
    UITableView *myTableView;
}

@end

RootViewController.m

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    myTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 100, 320, 300)];
    myTableView.delegate=self;
    myTableView.dataSource=self;
    [self.view addSubview:myTableView];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
    }
    cell.textLabel.text=@"1";
    return cell;

}
//点击的时候有动画效果
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [UIView beginAnimations:@"animationID" context:nil];
    [UIView setAnimationDuration:0.5f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationRepeatAutoreverses:NO];
    switch (indexPath.row) {
        case 0:
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[tableView cellForRowAtIndexPath:indexPath] cache:YES];
            break;
        case 1:
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[tableView cellForRowAtIndexPath:indexPath] cache:YES];
            break;
        case 2:
            [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:[tableView cellForRowAtIndexPath:indexPath] cache:YES];
            break;
        case 3:
            [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:[tableView cellForRowAtIndexPath:indexPath] cache:YES];
            break;
        default:
            break;
    }

    [UIView commitAnimations];
}
时间: 2024-08-06 16:52:31

点击cell时动画效果的相关文章

用C3中的animation和transform写的一个模仿加载的时动画效果

用用C3中的animation和transform写的一个模仿加载的时动画效果! 不多说直接上代码; html标签部分 <div class="wrap"> <h2>用C3中的animation和transform写的一个模仿加载的时动画效果</h2> <div class="demo"> <div></div> <div></div> <div></d

解决点击cell时,UILabel的背景颜色消失的问题

-(void)setSelected:(BOOL)selected animated:(BOOL)animated{ [super setSelected:selected animated:animated]; _lblGuanFang.backgroundColor = [ColorUtil getColor:@"7ab6f5" alpha:1.0]; } -(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated

【iOS开发-9】图片属性介绍,实现类似于“点击关注”的动画效果,以及顺便实现一个开始/停止按钮切换功能

(1)如果是按钮触发一个事件方法,我们只需要用(id)sender把控件对象传递进来,这个方法就能处理控件属性值:而如果方法需要处理其他对象,那么一个方法,就是把这个对象设置为全局变量,这样所有的方法都可以使用这个对象,并设置它的属性,我们这里的imgView2就是这样,可以在方法中,控制它停止还是开始. (2)UIImage和UIImageView通常是一对,UIImage的对象只是把图片添加到程序里面,但它不是视图无法被加载显示在APP中,但是UIImageView是一个视图,可以把UIIm

等待时动画效果的实现

当我们在请求网络时加载页面时有个动作效果,效果如下: 源代码可以网上找开源项目Coding.net,上面的效果原理为两张图片组合,外面那个则为动画转动,里面的图标则是透明度的变化:主要代码如下: 1:把它封装在EaseLoadingView里面 @interface EaseLoadingView : UIView @property (strong, nonatomic) UIImageView *loopView, *monkeyView; @property (assign, nonato

导航控制器切换时动画效果

今天写了一下关于导航栏切换时的不同的效果,直接上代码: 下面是在第一个Vc的touches方法进行切换的. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ // CATransition 有很多类型:@"rippleEffect", @"cube", @"moveln", @"reveal", @"fa

UITableView中cell点击的绚丽动画效果

本人视频教程系类   iOS中CALayer的使用 效果图: 源码: YouXianMingCell.h 与 YouXianMingCell.m // // YouXianMingCell.h // CellAnimation // // Created by YouXianMing on 14/12/27. // Copyright (c) 2014年 YouXianMing. All rights reserved. // #import <UIKit/UIKit.h> @interfac

窗体 dialog 弹出时动画效果

1.先创建 anim中的 xml  动画文件 <?xml version="1.0" encoding="utf-8"? > <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="0.1" android:toXScale="1" android:f

cell的动画效果,加载更多时候的波浪效果(既整个cell的波浪效果)

1.波浪效果是在tableView 上的cell上实现的,在cell.m中写如下代码: - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; [self buttonAnimation]; } 2.动画方法: - (CAAnimation *)animationRotate { //    UIButton *theButton =

窗口 dialog 弹出时动画效果

1.先创建 anim中的 xml  动画文件 <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="0.1" android:toXScale="1" android:fr