Add UIActivityIndicatorView into UIBarButton

后端 未结 6 1558
忘了有多久
忘了有多久 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条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 03:35

    Use this Methods

    -(void)startAniatingActivityIndicator{
    @try {
        activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
        activityIndicator.frame = CGRectMake(self.window.frame.size.width-30, 32.5, activityIndicator.bounds.size.width, activityIndicator.bounds.size.height);
        [self.window addSubview:activityIndicator];
        [activityIndicator startAnimating];
        [self.window bringSubviewToFront:activityIndicator];
    }
    @catch (NSException *exception) {
    
    }
    @finally {
    
    }
    

    }

    -(void)stopAniatingActivityIndicator{
    [activityIndicator stopAnimating];
    [activityIndicator removeFromSuperview];
    activityIndicator = nil;
    

    }

提交回复
热议问题