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

前端 未结 7 1923
情歌与酒
情歌与酒 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:14

    You can add a UIActivityIndicatorView to whichever view is "loading":

    CGRect mainBounds = [[UIScreen mainScreen] bounds];
    CGRect indicatorBounds = CGRectMake(mainBounds.size.width / 2 - 12,
        mainBounds.size.height / 2 - 12, 24, 24);
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]
        initWithFrame:indicatorBounds]];
    indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
    [indicator startAnimating];
    [yourLoadingView addSubview:indicator];
    

提交回复
热议问题