您的位置:首页 > 产品设计 > UI/UE

UIImageView实现简单动画

2016-09-28 09:25 357 查看
关于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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: