iOS 动画大全(附带gif图片效果)

iOS 动画大全(附带gif图片效果), 在实际的开发当中为了达到界面美化的效果,我们经常需要在项目中使用各种动画,在增强界面的动感。总结了个人的开发经验,下面介绍最常用的动画打全(根据图片效果自行选用吧):


  • UIImage类似美团袋鼠奔跑的动画
    这里写图片描述
    动画组图片
    这里写图片描述
-(UIImageView *)imageView{
    if (!_imageView) {
        _imageView = [[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 100, 100)];
        _imageView.center = self.view.center;
    }
    return _imageView;
}
 - (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.imageView];
    //会自动查找loading_1,loading_2直到找不到图片为止
    UIImage *image = [UIImage animatedImageNamed:@"loading_" duration:1];
    self.imageView.image = image;
}

  • NSTimer定时器动画
    这里写图片描述
-(UIImageView *)imageView{
    if (!_imageView) {
        _imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,100,50,50)];
        UIImage *image = [UIImage animatedImageNamed:@"loading_" duration:0.5];
        _imageView.image = image;
    }
    return _imageView;
}
 - (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.imageView];
    [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(changeLocationTimer:) userInfo:nil repeats:YES];// 方式一
    [self changeLocation];// 方式二
}
-(void)changeLocationTimer:(id)timer{
    CGRect frame = self.imageView.frame;
    frame.origin.x += 1;
    if (frame.origin.x >= self.view.bounds.size.width) {
        frame.origin.x = -frame.size.width;
    }
    self.imageView.frame = frame
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值