Skip to content

Instantly share code, notes, and snippets.

View muukii's full-sized avatar
✈️
We live in a twilight world.

Hiroshi Kimura muukii

✈️
We live in a twilight world.
View GitHub Profile
let backgroundView = UIView.mock(backgroundColor: .neon(.violet))
let box1 = UIView.mock(backgroundColor: .neon(.red), preferredSize: .largeSquare)
let box2 = UIView.mock(backgroundColor: .neon(.yellow), preferredSize: .largeSquare)
view.addSubview(backgroundView)
view.addSubview(box1)
view.addSubview(box2)
backgroundView.translatesAutoresizingMaskIntoConstraints = false
box1.translatesAutoresizingMaskIntoConstraints = false
/// For Transition
public final class ComposedCornerView: CodeBasedView {
private let topRightMaskView = UIView()
private let topLeftMaskView = UIView()
private let bottomRightMaskView = UIView()
private let bottomLeftMaskView = UIView()
private let topRightView = UIView()
private let topLeftView = UIView()
import ObjectiveC
import UIKit
let swizzle: Void = {
print("swizzle")
method_exchangeImplementations(
class_getInstanceMethod(UIScrollView.self, #selector(setter:UIScrollView.contentInset))!,
class_getInstanceMethod(UIScrollView.self, #selector(UIScrollView._mmm_setContentInset))!
@muukii
muukii / AppDelegate.swift
Last active May 31, 2021 12:44
Storybook-ios demo app starter template
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let newWindow = UIWindow()
//
import AsyncDisplayKit
import Foundation
import KeyboardGuide
import AppFoundation
/**
A sub-class of ASCollectionNode that supports handling the height of the Keyboard.
Using `KeyboardGuide`, it changes its contentInset and scroll-indicator regarding the relative height of the Keyboard.
open class ZStackView: UIView {
public init(views: [UIView]) {
super.init(frame: .zero)
views.forEach { view in
addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
//
import Foundation
public final class InputFilter {
private final class Storage<T> {
let lock = NSLock()
//: [Previous](@previous)
import Foundation
final class FilterStorage {
private var storage: [String: Any] = [:]
func comparer<T>(for key: String) -> ((T) -> Bool)? {
guard let object = storage[key] else {
@muukii
muukii / Drawrect Animation
Created February 10, 2014 13:08
Drawrect Animation
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
[super setHighlighted:highlighted];
[self setNeedsDisplay];
if (animated) {
[UIView transitionWithView:self duration:0.1
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[self.layer displayIfNeeded];
} completion:nil];
}
extension CGImage {
enum Flipping {
case vertically
case horizontally
}
func rotated(angle: CGFloat, flipping: Flipping? = nil) throws -> CGImage
{
guard angle != 0 else {