Skip to content

Instantly share code, notes, and snippets.

View mycroftcanner's full-sized avatar

Mycroft Canner mycroftcanner

  • Romanova
View GitHub Profile
@mycroftcanner
mycroftcanner / HostingNode.swift
Created October 21, 2019 00:11
Wraps a SwiftUI View inside a ASDisplayNode
//
// HostingNode.swift
//
import AsyncDisplayKit
import SwiftUI
class HostingNode: ASDisplayNode {
var viewController: UIViewController?
let userScript = WKUserScript(source: source,
injectionTime: .atDocumentEnd,
forMainFrameOnly: true)
let userContentController = WKUserContentController()
userContentController.addUserScript(userScript)
let configuration = WKWebViewConfiguration()
configuration.userContentController = userContentController
return configure(WKWebView(
frame: .zero,
configuration: configure(WKWebViewConfiguration()) {
$0.userContentController = configure(WKUserContentController()) {
$0.addUserScript(
WKUserScript(
source: source,
injectionTime: .atDocumentEnd,
forMainFrameOnly: true
)
@mycroftcanner
mycroftcanner / SwiftUINavViewTabViewAppearance.swift
Created October 3, 2019 09:48
SwiftUI hack: NavigationView and TabView's appearance
// SwiftUI hack: NavigationView and TabView's appearance
import UIkit
extension UINavigationController {
override open func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
navigationBar.standardAppearance = appearance