您好,欢迎来到化拓教育网。
搜索
您的当前位置:首页简单动画使用

简单动画使用

来源:化拓教育网
  • 在程序中使用动画的几种方法

    • 直接创建动画
    // 动画开始
    [UIView beginAnimations:nil context:nil];
    // 设置延迟时间
    [UIView setAnimationDuration:1];
    // 设置委托
    [UIView setAnimationDelegate:self];
    // 动画结束后执行
    [UIView setAnimationDidStopSelector:@selector(stop)];
    // 动画开始前执行
    [UIView setAnimationWillStartSelector:@selector(start)];
    CGFloat y = self.image.frame.size.height - self.scrollView.frame.size.height;
    self.scrollView.contentOffset = CGPointMake(self.scrollView.contentOffset.x, y);
    // 提交动画,否则没有动画
    [UIView commitAnimations];
    
    • 类方法
    CGPoint offset = CGPointMake(self.scrollView.contentOffset.x, 0);
    [self.scrollView setContentOffset:offset animated:YES];
    
    • block
    [UIView animateWithDuration:1 animations:^{
            self.scrollView.contentOffset = CGPointMake(0, self.scrollView.contentOffset.y);
        } completion:^(BOOL finished){
            if(finished)
            {
                 NSLog(@"执行完毕");
            }
        }];
    

Copyright © 2019- huatuo9.cn 版权所有 赣ICP备2023008801号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务