UITableViewCell的一些動畫

UITableViewCell的一些動畫

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //[self leftInsertAnimation:cell];
    //[self springAnimation_1:cell];
    //[self springAnimation_2:cell];
    //[self left3DAnimation:cell];
    [self flyInAnimation:cell];
}

1、左側(cè)插入動畫

-(void) leftInsertAnimation:(UITableViewCell*)cell{
    CGPoint center = cell.center;
    CGPoint orgCenter = center;
    center.x += cell.bounds.size.width;
    cell.center = center;

    [UIView animateWithDuration:0.5 animations:^{
        cell.center = orgCenter;
    }];
}

2、彈簧效果

-(void) springAnimation_1:(UITableViewCell*)cell{
    CGPoint center = cell.center;
    CGPoint orgCenter = center;
    center.y += cell.bounds.size.height;
    cell.center = center;
    
    [UIView animateWithDuration:0.5 animations:^{
        cell.center = orgCenter;
    }];
}

3、折疊展開效果

-(void) springAnimation_2:(UITableViewCell*)cell{
    
    cell.transform = CGAffineTransformMakeTranslation(0, -80);
    
    [UIView animateWithDuration:0.5 animations:^{
        cell.transform = CGAffineTransformIdentity;
    }];
}

4、左側(cè)3D變幻效果

-(void) left3DAnimation:(UITableViewCell*) cell{
    CATransform3D rotation;
    rotation = CATransform3DMakeRotation( (90.0*M_PI)/180, 0.0, 0.7, 0.4);
    rotation.m34 = 1.0/ -600;
    
    cell.layer.shadowColor = [[UIColor blackColor]CGColor];
    cell.layer.shadowOffset = CGSizeMake(10, 10);
    cell.alpha = 0;
    cell.layer.transform = rotation;
    cell.layer.anchorPoint = CGPointMake(0, 0.5);
    
    [UIView beginAnimations:@"rotation" context:NULL];
    [UIView setAnimationDuration:0.8];
    
    cell.layer.transform = CATransform3DIdentity;
    cell.alpha = 1;
    cell.layer.shadowOffset = CGSizeMake(0, 0);
        
    [UIView commitAnimations];
}

5、底部飛入效果

-(void) flyInAnimation:(UITableViewCell*) cell{

    cell.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1);
    //x和y的最終值為1
    [UIView animateWithDuration:1 animations:^{
        cell.layer.transform = CATransform3DMakeScale(1, 1, 1);
    }];
}

6、繞Z軸旋轉(zhuǎn)

cell.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1.0);
    [UIView animateWithDuration:0.4 animations:^{
        cell.layer.transform = CATransform3DMakeScale(1.0, 1.0, 1.0);
    }];

另:也可根據(jù)indexPath來控制舊數(shù)據(jù)和新數(shù)據(jù)是否動畫,自己可根據(jù)需求自定義動畫效果

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、簡介 <<UITableView(或簡單地說,表視圖)的一個實例是用于顯示和編輯分層列出的信息的一種手段 <<...
    無邪8閱讀 10,959評論 3 3
  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 15,256評論 4 61
  • 概述在iOS開發(fā)中UITableView可以說是使用最廣泛的控件,我們平時使用的軟件中到處都可以看到它的影子,類似...
    liudhkk閱讀 9,296評論 3 38
  • 使用一個list包裹著button和一個div,點擊button后才顯示div里面的內(nèi)容,加了點特效(漸變)讓他變...
    undefind33閱讀 562評論 0 0
  • 1 我在聯(lián)想當(dāng)大客戶經(jīng)理做銷售的時候,遇到公家單位的這類型客戶感覺還挺好談的,因為公家單位購買聯(lián)想的電腦和服務(wù)器都...
    王仲海閱讀 644評論 1 2

友情鏈接更多精彩內(nèi)容