Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import WebKit
- class WebShadVC: UIViewController {
- let wv1: WKWebView = WKWebView()
- let wv2: WKWebView = WKWebView()
- override func viewDidAppear(_ animated: Bool) {
- super.viewDidAppear(animated)
- view.backgroundColor = .yellow
- wv1.translatesAutoresizingMaskIntoConstraints = false
- view.addSubview(wv1)
- wv2.translatesAutoresizingMaskIntoConstraints = false
- view.addSubview(wv2)
- let g = view.safeAreaLayoutGuide
- NSLayoutConstraint.activate([
- wv1.topAnchor.constraint(equalTo: g.topAnchor, constant: 20.0),
- wv1.leadingAnchor.constraint(equalTo: g.leadingAnchor, constant: 20.0),
- wv1.trailingAnchor.constraint(equalTo: g.trailingAnchor, constant: -20.0),
- wv1.heightAnchor.constraint(equalToConstant: 80.0),
- wv2.topAnchor.constraint(equalTo: wv1.bottomAnchor, constant: 20.0),
- wv2.leadingAnchor.constraint(equalTo: g.leadingAnchor, constant: 20.0),
- wv2.trailingAnchor.constraint(equalTo: g.trailingAnchor, constant: -20.0),
- wv2.heightAnchor.constraint(equalTo: wv1.heightAnchor),
- ])
- var titleColor: String?
- let htmlstr: String = "<p>geschieht</p>"
- let str = "<!DOCTYPE html> <html> <head> <link href='https://fonts.googleapis.com/css?family=Fira Sans Condensed' rel='stylesheet'> <style> body {font-family: 'Fira Sans Condensed';} .image {width: 100%; height: auto;} .bg-white { background: rgba(255, 255, 255, .7); border-radius:40px; padding: 20px; }html { padding: 10px;} h2 {\(titleColor ?? "font-size:40pt; color:#000000;")} p{ font-size:26pt; {font-family: 'Fira Sans', sans-serif;}.bold{font-weight:bold;}.italic{font-style: italic;}.oblique{font-style: oblique;}} strong{font-size:30pt} </style> </head> <body><div class='bg-white'>\(htmlstr) </div> </body> </html>"
- wv1.loadHTMLString(str, baseURL: nil)
- wv2.loadHTMLString(str, baseURL: nil)
- wv1.isOpaque = true
- wv2.isOpaque = false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement