Advertisement
Don_Mag

Untitled

Aug 11th, 2023 (edited)
1,810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.90 KB | None | 0 0
  1. import UIKit
  2. import WebKit
  3.  
  4. class WebShadVC: UIViewController {
  5.    
  6.     let wv1: WKWebView = WKWebView()
  7.     let wv2: WKWebView = WKWebView()
  8.  
  9.     override func viewDidAppear(_ animated: Bool) {
  10.         super.viewDidAppear(animated)
  11.        
  12.         view.backgroundColor = .yellow
  13.  
  14.         wv1.translatesAutoresizingMaskIntoConstraints = false
  15.         view.addSubview(wv1)
  16.         wv2.translatesAutoresizingMaskIntoConstraints = false
  17.         view.addSubview(wv2)
  18.  
  19.         let g = view.safeAreaLayoutGuide
  20.         NSLayoutConstraint.activate([
  21.            
  22.             wv1.topAnchor.constraint(equalTo: g.topAnchor, constant: 20.0),
  23.             wv1.leadingAnchor.constraint(equalTo: g.leadingAnchor, constant: 20.0),
  24.             wv1.trailingAnchor.constraint(equalTo: g.trailingAnchor, constant: -20.0),
  25.             wv1.heightAnchor.constraint(equalToConstant: 80.0),
  26.            
  27.             wv2.topAnchor.constraint(equalTo: wv1.bottomAnchor, constant: 20.0),
  28.             wv2.leadingAnchor.constraint(equalTo: g.leadingAnchor, constant: 20.0),
  29.             wv2.trailingAnchor.constraint(equalTo: g.trailingAnchor, constant: -20.0),
  30.             wv2.heightAnchor.constraint(equalTo: wv1.heightAnchor),
  31.            
  32.         ])
  33.        
  34.         var titleColor: String?
  35.        
  36.         let htmlstr: String = "<p>geschieht</p>"
  37.        
  38.         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>"
  39.  
  40.         wv1.loadHTMLString(str, baseURL: nil)
  41.         wv2.loadHTMLString(str, baseURL: nil)
  42.  
  43.         wv1.isOpaque = true
  44.         wv2.isOpaque = false
  45.        
  46.     }
  47.    
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement