Skip to content

Instantly share code, notes, and snippets.

Avatar
🤠
£$%&in'

Mycroft Canner mycroftcanner

🤠
£$%&in'
  • Romanova
View GitHub Profile
@mycroftcanner
mycroftcanner / HostingNode.swift
Created Oct 21, 2019
Wraps a SwiftUI View inside a ASDisplayNode
View HostingNode.swift
//
// HostingNode.swift
//
import AsyncDisplayKit
import SwiftUI
class HostingNode: ASDisplayNode {
var viewController: UIViewController?
View webView.swift
let userScript = WKUserScript(source: source,
injectionTime: .atDocumentEnd,
forMainFrameOnly: true)
let userContentController = WKUserContentController()
userContentController.addUserScript(userScript)
let configuration = WKWebViewConfiguration()
configuration.userContentController = userContentController
View gist:a272cdbb97182063e66a8f86d24ebde9
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 Oct 3, 2019
SwiftUI hack: NavigationView and TabView's appearance
View SwiftUINavViewTabViewAppearance.swift
// 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
You can’t perform that action at this time.