ios tableView滑动动画

来源:互联网 发布:厦门软件培训 编辑:程序博客网 时间:2024/05/22 01:59

今天就分享给大家一个比较实用的动画

ios 中经常用的到列表 tableView, 那么大家在滑动中是否感觉有些单调呢?

如果滑动的时候有些动画 是否会更好些呢? 这些问题也是我所考虑的

下面就教大家2种简单实用的动画 

这些效果都是我亲测的,大家可以放心使用


第一种是模仿百度贴吧客户端 滑动的效果

<span style="font-size:18px;">- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{            if (indexPath.row>=tableViewNum) {                cell.contentView.alpha = 0.1;        CGAffineTransform transformScale = CGAffineTransformMakeScale(2,2);    CGAffineTransform transformTranslate = CGAffineTransformMakeTranslation(0, 0);        cell.contentView.transform = CGAffineTransformConcat(transformScale, transformTranslate);        [tableView bringSubviewToFront:cell.contentView];    [UIView animateWithDuration:0.5 animations:^{        cell.contentView.alpha = 1;        cell.contentView.transform = CGAffineTransformIdentity;    } completion:nil];        tableViewNum= indexPath.row;    }}</span>

这份代码直接复制黏贴, 就可以使用了

  至于 if  是为了第一次加载才游动画显示

如果去掉if  则每次滑动都会有动画显示,

那么下面是第2种从左或右加载



/*
    CGFloat rotationAngleDegrees = 0;
    CGFloat rotationAngleRadians = rotationAngleDegrees * (M_PI/180);
    CGPoint offsetPositioning = CGPointMake(-200, -20);
    CATransform3D transform = CATransform3DIdentity;
    transform = CATransform3DRotate(transform, rotationAngleRadians, 0.0, 0.0, 1.0);
    transform = CATransform3DTranslate(transform, offsetPositioning.x, offsetPositioning.y, 0.0);
    
    
    UIView *card = [cell contentView];
    card.layer.transform = transform;
    card.layer.opacity = 0.1;
    
    
    
    [UIView animateWithDuration:0.5f animations:^{
        card.layer.transform = CATransform3DIdentity;
        card.layer.opacity = 1;
    }];
 */


和上面的使用方法一样

是不是很简单呢?

有一点请注意  动画效果只支持6.0以上



最后请喜欢我博客或帮助到你的人 ,给予我一点点支持,你的支持才是我最大的动力。

0 0
原创粉丝点击