因为我是iPhone的新手,所以我有一个小问题。我想在我的应用程序中使用UIActivityIndicatorView。由于我使用indicatorView成功,但我想显示带有模糊背景的IndicatorView,这样我就无法点击当前活动上的按钮。
请朋友
指导我学习一些教程或一些代码。
提前感谢一堆
答案 0 :(得分:4)
在这里,你这是我的实现,但你可以修改。在app Delegate中发布代码并在您的应用程序中的任何地方使用。
#pragma mark -
#pragma mark Waiting View
- (void)showWaitingView {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CGRect frame = CGRectMake(90, 190, 32, 32);
UIActivityIndicatorView* progressInd = [[UIActivityIndicatorView alloc] initWithFrame:frame];
[progressInd startAnimating];
progressInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
frame = CGRectMake(130, 193, 140, 30);
UILabel *waitingLable = [[UILabel alloc] initWithFrame:frame];
waitingLable.text = @"Processing...";
waitingLable.textColor = [UIColor whiteColor];
waitingLable.font = [UIFont systemFontOfSize:20];;
waitingLable.backgroundColor = [UIColor clearColor];
frame = [[UIScreen mainScreen] applicationFrame];
UIView *theView = [[UIView alloc] initWithFrame:frame];
theView.backgroundColor = [UIColor blackColor];
theView.alpha = 0.7;
theView.tag = 999;
[theView addSubview:progressInd];
[theView addSubview:waitingLable];
[progressInd release];
[waitingLable release];
[window addSubview:[theView autorelease]];
[window bringSubviewToFront:theView];
[pool drain];
}
- (void)removeWaitingView {
UIView *v = [window viewWithTag:999];
if(v) [v removeFromSuperview];
}
答案 1 :(得分:0)
首先,您必须添加一个视图,其中黑色背景和 alpha 0.3 等。然后在视图上方添加活动指示器。
// an example
[self.view addSubview:aSemiTransparentBlackView];
[self.view addSubview:activityIndicator];
答案 2 :(得分:0)
也可以尝试:
-(UIAlertView *)showActivityIndicator :(NSString *)message
{
alertViewProgress = [[UIAlertView alloc] initWithTitle:message message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
UIActivityIndicatorView *activity =[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(120,50,37,37)];
activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[activity startAnimating];
[alertViewProgress addSubview:activity];
[activity release];
[alertViewProgress show];
return alertViewProgress;
}