<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
- (void)getNetworkingStatus{//私有方法
NSArray *subViews = [[[[UIApplication sharedApplication] valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];//获取前台页面的状态栏,注意如果隐藏了状态,此处无法取值。
//快枚举遍历状态栏视图集合,查找到需要的网络类型视图并存储
[subViewsenumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx,BOOL *_Nonnull stop) {
if([obj isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]){
dataView = obj;
}
}];
switch ([[dataView valueForKey:@"dataNetworkType"] integerValue]) {
case 0:NSLog(@"no wifi");break;
case1:NSLog(@"2G");break;
case2:NSLog(@"3G");break;
default:NSLog(@"wifi");break;
break;
}
}
//导航栏全透明设置ß
- (void)setNavigationBarType{
self.tabBarController.tabBar.hidden = YES;
self.navigationController.navigationBar.translucent = YES;
UIColor *col = [UIColor clearColor];
CGRect rec = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 64);
UIGraphicsBeginImageContext(rec.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, col.CGColor);
CGContextFillRect(context, rec);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.clipsToBounds = YES;
}
//导航栏全透明设置ß
- (void)setNavigationBarType{
self.tabBarController.tabBar.hidden = YES;
self.navigationController.navigationBar.translucent = YES;
UIColor *col = [UIColor clearColor];
CGRect rec = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 64);
UIGraphicsBeginImageContext(rec.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, col.CGColor);
CGContextFillRect(context, rec);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.clipsToBounds = YES;
}