Skip to content

Instantly share code, notes, and snippets.

@bengottlieb
bengottlieb / VisualEffectBackground.swift
Created March 30, 2021 00:12
a minimal SwiftUI view that implements background blur on macOS
import SwiftUI
public struct VisualEffectBackground: NSViewRepresentable {
var material: NSVisualEffectView.Material = .contentBackground
var blendingMode: NSVisualEffectView.BlendingMode = .behindWindow
var isEmphasized = false
public init(material: NSVisualEffectView.Material = .contentBackground, blendingMode: NSVisualEffectView.BlendingMode = .behindWindow, emphasized: Bool = false) {
self.material = material
self.blendingMode = blendingMode
@bengottlieb
bengottlieb / PSPDFUIKitMainThreadGuard.m
Created March 1, 2017 02:55 — forked from steipete/PSPDFUIKitMainThreadGuard.m
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
//
// MainThreadGuard.m
// Honor
//
// Created by Ben Gottlieb on 2/28/17.
// Copyright © 2017 Ben Gottlieb. All rights reserved.
//
#import <Foundation/Foundation.h>