有人知道如何显示一个带旋转活动指示器的圆角正方形吗?它在许多应用程序中使用。如果你不知道我在说什么,它看起来像当你在Mac上更改音量时的指示器,但背景较暗。我不确定它是否内置于iOS中还是由某人制作。
就像这篇文章中的那个一样,但不是全屏幕,只是活动指示器 如何在iPhone上创建全屏模态状态显示?
有人知道如何显示一个带旋转活动指示器的圆角正方形吗?它在许多应用程序中使用。如果你不知道我在说什么,它看起来像当你在Mac上更改音量时的指示器,但背景较暗。我不确定它是否内置于iOS中还是由某人制作。
就像这篇文章中的那个一样,但不是全屏幕,只是活动指示器 如何在iPhone上创建全屏模态状态显示?
这是我在展示那种指示器时使用的东西。
UIView *loading = [[UIView alloc] initWithFrame:CGRectMake(100, 200, 120, 120)];
loading.layer.cornerRadius = 15;
loading.opaque = NO;
loading.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.6f];
UILabel *loadLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 25, 81, 22)];
loadLabel.text = @"Loading";
loadLabel.font = [UIFont boldSystemFontOfSize:18.0f];
loadLabel.textAlignment = UITextAlignmentCenter;
loadLabel.textColor = [UIColor colorWithWhite:1.0f alpha:1.0f];
loadLabel.backgroundColor = [UIColor clearColor];
[loading addSubview:loadLabel];
[loadLabel release];
UIActivityIndicatorView *spinning = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinning.frame = CGRectMake(42, 54, 37, 37);
[spinning startAnimating];
[loading addSubview:spinning];
[spinning release];
loading.frame = CGRectMake(100, 200, 120, 120);
然后,您只需将“loading”视图添加到您选择的视图中即可。
希望这是您所需要的。
你的截图很可能是使用David Sinclair的DSActivityView模块,具体来说是其中的DSBezelActivityView组件。如果不是,那它应该是一个相似的副本。
http://www.dejal.com/developer/dsactivityview
我经常使用DSActivityView库,非常好用。在拉取数据时弹出此组件能够让用户和客户感到满意。
-setupBackground
方法来实现这一点:- (void)setupBackground;
{
[super setupBackground];
self.backgroundColor = [UIColor clearColor];
}
UIActivityIndicatorView *activityIndicator= [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
activityIndicator.layer.cornerRadius = 05;
activityIndicator.opaque = NO;
activityIndicator.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.6f];
activityIndicator.center = self.view.center;
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
[activityIndicator setColor:[UIColor colorWithRed:0.6 green:0.8 blue:1.0 alpha:1.0]];
[self.view addSubview: activityIndicator];