Created
May 17, 2024 14:06
-
-
Save geriux/31a25c1f713a5fa3e17b5fd9d15484d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import WebKit | |
class ViewController: UIViewController { | |
var gutenbergView: GutenbergView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
gutenbergView = GutenbergView() | |
let padding: CGFloat = 30 | |
let viewWidth = view.frame.width | |
let viewHeight = view.frame.height | |
let maxHeight: CGFloat = 300 | |
let height = min(viewHeight / 2 - 2 * padding, maxHeight) | |
let centeredFrame = CGRect(x: padding, y: (viewHeight - height + 300) / 2, width: viewWidth - 2 * padding, height: height) | |
gutenbergView.view.frame = centeredFrame | |
gutenbergView.view.layer.borderWidth = 1 | |
gutenbergView.view.layer.borderColor = UIColor.black.cgColor | |
gutenbergView.view.clipsToBounds = true | |
view.addSubview(gutenbergView.view) | |
gutenbergView.didMove(toParent: self) | |
} | |
@objc func callRequestHTML() { | |
if (gutenbergView != nil) { | |
gutenbergView.requestHTML() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment