IOS控件-UIWebView

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_21153627/article/details/84133841

简单的UIWebView操作、

//加载网页
        let webView1 = UIWebView(frame: CGRect(x: 0, y: 20, width: 400, height: 300))
        let request = URLRequest(url: URL(string: "https://www.baidu.com")!)
        webView1.loadRequest(request)
        self.view.addSubview(webView1)
        
        //加载本地html
        let webView2 = UIWebView(frame: CGRect(x: 0, y: 350, width: 400, height: 300))
        let html = "<font color='blue'>Hello!!</font>,<B>Xcode</B> and <i>Swift</>"
        webView2.loadHTMLString(html, baseURL: nil)
        self.view.addSubview(webView2)

猜你喜欢

转载自blog.csdn.net/qq_21153627/article/details/84133841