How to implement a loading animation when navigating in a iPhone app?

前端 未结 7 1918
情歌与酒
情歌与酒 2021-02-04 18:41

It seems like a pretty simple problem, but I have been unable to find any good answers.

What I\'m trying to do is to make some sort of animation while some function is l

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-04 19:10

    you can add an UIActivityIndicatorView as a subview to a view and when the action is over you can remove it from superview...

    UIActivityIndicatorView  *av = [[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
    av.frame=CGRectMake(145, 160, 25, 25);
    av.tag  = 1;
    [yourView addSubview:av];
    [av startAnimating];
    

    removing it

    UIActivityIndicatorView *tmpimg = (UIActivityIndicatorView *)[yourView viewWithTag:1];
    [tmpimg removeFromSuperview];
    

    hope it helps...

提交回复
热议问题