UIApplication * app =[UIApplication sharedApplication];
NSArray *children =[[[app valueForKeyPath:@"statusBar"] valueForKeyPath:@"foregroundView"] subviews];
int type = 0;
for (id child in children) {
if ([child isKindOfClass:NSClassFromString(@"UIStatusBarDataNetworkItemView")]) {
type = [[child valueForKeyPath:@"dataNetworkType"]intValue];
}
}
//0 - 无网络; 1 - 2G; 2 - 3G; 3 - 4G; 5 - WIFI
NSLog(@"网络状态----%d",type);