- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // UIApplication *app = [UIApplication sharedApplication]; // UIApplication *app1 = [UIApplication sharedApplication]; //// UIApplication *app2 = [[UIApplication alloc] init]; // NSLog(@"%p - %p ", app, app1); UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; [btn setTitle:@"点我啊" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(onClick) forControlEvents:UIControlEventTouchUpInside]; btn.backgroundColor = [UIColor redColor]; [self.view addSubview:btn]; } - (void)onClick { // NSLog(@"被点了"); UIApplication *app = [UIApplication sharedApplication]; // 设置应用程序图标上的数字 // app.applicationIconBadgeNumber = 998; // 设置状态栏的联网动画 // app.networkActivityIndicatorVisible = YES; // 设置状态栏的样式 // app.statusBarStyle = UIStatusBarStyleLightContent; // [app setStatusBarStyle:UIStatusBarStyleLightContent animated:YES]; // 设置状态栏是否隐藏 // app.statusBarHidden = YES; // [app setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; /* URL:统一资源定位符 , 用来唯一的表示一个资源 URL: 协议头://主机地址/资源路径 网络资源:http://www.baidu.com/images/20140603/abc.png 本地资源:file:///users/apple/desktop/abc.png */ NSURL *url = [NSURL URLWithString:@"http://ios.itcast.cn"]; [app openURL:url]; } //- (UIStatusBarStyle)preferredStatusBarStyle //{ // return UIStatusBarStyleLightContent; //} //- (BOOL)prefersStatusBarHidden //{ // return YES; //}
时间: 2024-11-05 16:25:27