Add UIActivityIndicatorView into UIBarButton

后端 未结 6 1563
忘了有多久
忘了有多久 2021-02-01 03:00

How do I add a UIActivityIndicatorView spinner circle into a UIBarButton, so that when a user taps on one of those buttons on the navigation bar, they see a spinner while the lo

6条回答
  •  -上瘾入骨i
    2021-02-01 03:40

    activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
    activityIndicator.hidesWhenStopped = YES;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator];
    

    Place the following where ever is needed:

    [activityIndicator startAnimating];
    [activityIndicator stopAnimating];
    

提交回复
热议问题