//网页加载完毕的回调,OCCSwift调用JS
func webViewDidFinishLoad(_ webView: UIWebView) {
//调用JS的DOM文档对象
let title = self.webview.stringByEvaluatingJavaScript(from: "document.title");
//调用JS的方法
self.webview.stringByEvaluatingJavaScript(from: "clickme()");
print(title ?? "")
}
//网页即将加载的回调,JS调用OC Swift
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
var urlString = request.url?.absoluteString
unsigned int count = 0;
Method *methods = class_copyMethodList([UITextField class], &count);
for (int i = 0; i < count; i++ ) {
Method method = methods[i];
NSString *string = NSStringFromSelector(method_getName(method));
NSLog(@"%@",string);
}
//修改 : _placeholderLabel
[self.textfield setValue:[UIColor redColor] forKeyPath:@"placeholderLabel.textColor"];
//修改 : placeholder
[self.textfield setValue:@"FUCK" forKey:@"placeholder"];
网友评论