更改状态栏颜色
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = [UIColor whiteColor];
}
解析链接中的文字
view.URLString = [urlstring stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
服务器返回的时间戳转换成时间
//一般服务器返回的时间戳是13位的,ios的时间戳是10位的
NSTimeInterval time = [recTime doubleValue]/1000;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *dateString = [formatter stringFromDate: date];
NSLog(@"服务器返回的时间戳对应的时间是:%@",dateString);
截取wkwebview里的视频URL
//在加载完成的方法里
NSString *JSStr = @"(document.getElementsByTagName(\"video\")[0]).src";
[webView evaluateJavaScript:JSStr completionHandler:^(id _Nullable response, NSError * _Nullable error) {
if (![response isEqual:[NSNull null]] && response != nil) {
NSLog(@"response == %@",response);
#warning maybe need a DIY videoplayer
} else {
NSLog(@"Mission for Catching videoURL is failed");
}
}];