根据状态栏的图片判断是3G或者是WiFI

/* Where

0 = No wifi or cellular

1 = 2G and earlier

2 = 3G

3 = 4G

4 = LTE

5 = Wifi

*/

- (NSNumber *)dataNetworkTypeFromStatusBar {

UIApplication *app = [UIApplication sharedApplication];

NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"]    subviews];

NSNumber *dataNetworkItemView = nil;

for (id subview in subviews) {

if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {

dataNetworkItemView = subview;

break;

}

}

return [dataNetworkItemView valueForKey:@"dataNetworkType"];

}

你可能感兴趣的:(根据状态栏的图片判断是3G或者是WiFI)