程序员iOS开发手机移动程序开发

展开动画demo

2018-06-06  本文已影响146人  honey缘木鱼

公司要求有个简单的动画效果,自己做了个小demo。demo地址(https://github.com/dt8888/AnimationShow
1.展开动画代码:

   [UIView beginAnimations:nil context:nil];
    _upBtn.transform = CGAffineTransformScale(CGAffineTransformIdentity,1,1);
    _upBtn.frame = CGRectMake((kScreenWidth-20)-80, 0, 40, 85);
    _delectBtn.transform = CGAffineTransformScale(CGAffineTransformIdentity,1,1);
    _delectBtn.frame = CGRectMake((kScreenWidth-20)-120, 0, 40, 85);
    [UIView commitAnimations];

2.关闭动画代码:

     [_editBtn setTitle:@"编    辑" forState:UIControlStateNormal];
    [UIView beginAnimations:nil context:nil];
    _upBtn.transform = CGAffineTransformScale(CGAffineTransformIdentity,1,1);
    _upBtn.frame = CGRectMake((kScreenWidth-20)-40, 0, 40, 85);
    _delectBtn.transform = CGAffineTransformScale(CGAffineTransformIdentity,1,1);
    _delectBtn.frame = CGRectMake((kScreenWidth-20)-40, 0, 40, 85);
    [UIView commitAnimations];

3.滑动关闭动画代码:

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    //循环显示的cell
    for (AnimationCell *item in self.visibleCells) {
        [item closeAnimationsBtn];
    }
}

4.点击关闭

-(void)closeOtherCellLeftSwipe:(NSIndexPath *)indexPath
{
    for (AnimationCell *item in self.visibleCells) {
        NSIndexPath *path = [self indexPathForCell:item];
        if(indexPath.section!=path.row){
            [item closeAnimationsBtn];
        }
    }
}

如有问题欢迎多多指教!

上一篇 下一篇

猜你喜欢

热点阅读