如何以ScrollWheel方式为Tableviewcells制作动画?,Swift

时间:2015-05-30 22:15:12

标签: ios uitableview swift animation

我试图动画我的tableview,使其在向上和向下滚动时看起来像滚轮。 Similar to this picture.

这是我在滚动时为tableview设置动画的代码。不幸的是,它丝毫不像滚轮。所以我的问题是,我需要做出哪些改变才能得到我想要的结果?我需要完全重写吗?我想我不需要SpriteKit吗?

       //setup the CATransform3D Structure
    var rotation:CATransform3D = CATransform3DMakeRotation(CGFloat((90.0*M_PI)/180), CGFloat(0.0), CGFloat(0.7), CGFloat(0.4))
    rotation.m34 = (1.0/(-600))

    //Define the initial state
    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)

    //!!!FIX for issue #1 Cell position wrong------------
    if(cell.layer.position.x != 0)
    {
        cell.layer.position = CGPointMake(0, cell.layer.position.y);
    }

    //Defines the final state after the animation
    UIView.animateWithDuration(0.8, animations: {
        cell.layer.transform = CATransform3DIdentity
        cell.alpha = 1
        cell.layer.shadowOffset = CGSizeMake(0, 0)
    }, completion: nil)

This is what the animation currently looks like

0 个答案:

没有答案