iOS UIActivityIndicatorView的简单使用
来源:互联网 发布:python 免费 ide 编辑:程序博客网 时间:2024/04/25 18:58
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor grayColor]; UIActivityIndicatorView *activityView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; activityView.frame=CGRectMake(60, 130, 200, 200);//其大小不变// activityView.center=CGPointMake(160, 230); [activityView startAnimating]; [self.window addSubview:activityView]; [activityView release]; [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInfo:) userInfo:activityView repeats:NO]; //设置通知栏的ActivityIndicator [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; [self.window makeKeyAndVisible]; return YES;}-(void)updateInfo:(NSTimer *)timer{ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; //获取 UIActivityIndicatorView *activityView=[timer userInfo]; //停止 [activityView stopAnimating]; //从父视图移除// [activityView removeFromSuperview]; }