UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 14, 14)];
[activityView sizeToFit];
[activityView setAutoresizingMask:(UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin)];

activityView.hidesWhenStopped = NO;

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:activityView];

[activityView startAnimating];


uiactivity指示器未显示在右上角的原因是什么?右上方的导航栏中未显示任何内容。

最佳答案

因为您未分配活动指示器的颜色
分配颜色,然后我将在导航栏中显示

activityView.color = [UIColor blackColor];

07-24 15:13