UIImageView实现简单动画

    xiaoxiao2023-03-24  5

    关于ios动画,自己在以往的开发中用到的很少,这次遇到这么个需求:在一个操作完成前我需要加上动画效果,其实只是两张图片不断替换。图片当然用UIImageview加载。在请教别人之后,知道了uiimageview使用动画的方法,我又把它跟MBProgressHUD相结合使用,代码如下:

     //添加开门动画

        MBProgressHUD * animationHud= [[MBProgressHUD alloc] initWithView:self.view];

        [animationHud setRemoveFromSuperViewOnHide:YES];

        UIView *view =[[UIView alloc]initWithFrame:CGRectMake(0,0, 57, 81)];

        UIImageView *imageview=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_open.png"]];

        imageview.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"icon_open_noCharacter"],[UIImage imageNamed:@"icon_close_noCharacter"],nil];

        imageview.animationDuration = 0.5f;

        imageview.animationRepeatCount = 0;    //0代表无限大

        imageview.userInteractionEnabled = YES;

        [imageview startAnimating];

        imageview.frame=view.frame;

        [view addSubview:imageview];

        [animationHud setCustomView:view];

        [animationHud setMode:MBProgressHUDModeCustomView];

        [self.view addSubview:animationHud];

        [animationHud show:YES];

    转载请注明原文地址: https://ju.6miu.com/read-1202435.html
    最新回复(0)