Skip to content

Instantly share code, notes, and snippets.

View JunyuKuang's full-sized avatar

Jonny JunyuKuang

View GitHub Profile
@JunyuKuang
JunyuKuang / ShareSheetHDREffectRemover
Created November 18, 2022 14:42
Remove the unexpected HDR effect on iOS Share Sheet when Dark Mode is off.
//
// ShareSheetHDREffectRemover.swift
// MIT license
//
// Copyright © 2022 Jonny Kuang (theSpringApp@gmail.com)
//
#if !targetEnvironment(macCatalyst)
/// Remove the unexpected HDR effect on iOS Share Sheet when Dark Mode is off.
@JunyuKuang
JunyuKuang / MacCatalystFastQuitHelper.swift
Last active October 14, 2022 03:43
Prevent Mac Catalyst apps from running in the background for a long time, after user explicitly quit it.
//
// MacCatalystFastQuitHelper
//
// Copyright © 2022 Jonny Kuang. MIT
//
import UIKit
enum MacCatalystFastQuitHelper {
@JunyuKuang
JunyuKuang / WWDCDownloadLinks.md
Last active July 30, 2023 16:58 — forked from IsaacXen/README.md
(Almost) Every WWDC videos download links for aria2c.
@JunyuKuang
JunyuKuang / NSLayoutConstraint+.swift
Created November 21, 2021 02:55
Helper methods for NSLayoutConstraint
//
// NSLayoutConstraint+.swift
// SpringUI
//
// Created by Jonny Kuang on 11/21/21.
// Copyright © 2021 Jonny Kuang. All rights reserved. (MIT license)
//
import Foundation
@JunyuKuang
JunyuKuang / Swizzle.swift
Last active September 26, 2023 05:17
Swift Swizzle API
import Foundation
@discardableResult
public func swizzleInstanceMethod(class aClass: AnyClass?, originalSelector: Selector, swizzledSelector: Selector) -> Bool {
swizzleMethod(class: aClass, originalSelector: originalSelector, swizzledSelector: swizzledSelector, isClassMethod: false)
}
@discardableResult
public func swizzleClassMethod(class aClass: AnyClass?, originalSelector: Selector, swizzledSelector: Selector) -> Bool {
swizzleMethod(class: aClass, originalSelector: originalSelector, swizzledSelector: swizzledSelector, isClassMethod: true)
@JunyuKuang
JunyuKuang / OverrideCatalystScaleFactor.swift
Last active September 29, 2024 00:58
Disable 77% scaling for Mac Catalyst apps. (Swift)
let overrideCatalystScaleFactor: Void = {
guard let sceneViewClass = NSClassFromString("UINSSceneView") as? NSObject.Type else {
return
}
if sceneViewClass.instancesRespond(to: NSSelectorFromString("scaleFactor")) {
// old
swizzleInstanceMethod(
class: sceneViewClass,
originalSelector: NSSelectorFromString("scaleFactor"),
swizzledSelector: #selector(swizzle_scaleFactor)
@JunyuKuang
JunyuKuang / JonnyKeyValueObserver.swift
Last active March 24, 2020 09:54
An NSKeyValueObservation replacement.
//
// JonnyKeyValueObserver.swift
//
// Copyright (c) 2020 Junyu Kuang <lightscreen.app@gmail.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@JunyuKuang
JunyuKuang / UIImage+NSToolbar.swift
Created October 22, 2019 03:07
[Mac Catalyst] a helper method that creates NSToolbar image with SF Symbol
//
// UIImage+NSToolbar.swift
// MobileReaderUI
//
// Created by Jonny Kuang on 10/12/19.
// Copyright © 2019 Junyu Kuang <lightscreen.app@gmail.com>. All rights reserved.
//
#if targetEnvironment(macCatalyst)
extension UIImage {
@JunyuKuang
JunyuKuang / AccentColorDemo.swift
Created October 20, 2019 06:10
Access accent color from Mac Catalyst app
//
// ViewController.swift
// UIKitAccentColor
//
// Created by Jonny Kuang on 10/20/19.
// Copyright © 2019 Jonny Kuang. All rights reserved.
//
import UIKit
@JunyuKuang
JunyuKuang / UIResponder+performWindowDrag.swift
Last active November 2, 2023 23:32
Customize/extend the window draggable area of your Mac Catalyst app.
//
// UIResponder+performWindowDrag.swift
// JonnyUtility
//
// Created by Jonny Kuang on 10/7/19.
// Copyright © 2019 Junyu Kuang <lightscreen.app@gmail.com>. All rights reserved.
//
import UIKit