Skip to content

Instantly share code, notes, and snippets.

View zenangst's full-sized avatar
🥪
Reminiscing about vacation

Christoffer Winterkvist zenangst

🥪
Reminiscing about vacation
View GitHub Profile
import Cocoa
class DeveloperToolsController {
let commandController: CommandController
init(commandController: CommandController) {
self.commandController = commandController
}
#if DEBUG
import UIKit
import Vaccine
class PlayerAttributesViewController: UIViewController {
let dataSource: UITableViewDataSource
var tableView: UITableView!
init(dataSource: UITableViewDataSource) {
self.dataSource = dataSource
super.init(nibName: nil, bundle: nil)
@zenangst
zenangst / Example2.swift
Last active April 18, 2018 08:25
How to rotate tvOS into portrait mode - Example 2
let frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.height, height: UIScreen.main.bounds.width)
let window = UIWindow(frame: frame)
let transformRotation = CGAffineTransform(rotationAngle: CGFloat(-270) * .pi / 180)
window.transform = transformRotation
@zenangst
zenangst / Example1.swift
Last active April 18, 2018 08:18
How to rotate tvOS into portrait mode - Example 1
let frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.height, height: UIScreen.main.bounds.width)
let window = UIWindow(frame: frame)
@zenangst
zenangst / Example2.swift
Last active May 24, 2018 05:25
Converting between view coordinate systems - Example 2
import Cocoa
import PlaygroundSupport
let frame = CGRect(origin: .zero,
size: .init(width: 150, height: 150))
let window = NSView(frame: frame)
window.wantsLayer = true
window.layer?.backgroundColor = NSColor.white.cgColor
let view = NSView(frame: CGRect(origin: .init(x: 25, y: 25),
@zenangst
zenangst / Example1.swift
Last active May 24, 2018 05:28
Converting between view coordinate systems - Example 1
import UIKit
let frame = CGRect(origin: .zero,
size: .init(width: 150, height: 150))
let window = UIWindow(frame: frame)
let rootView = UIView(frame: window.bounds)
rootView.backgroundColor = .white
window.addSubview(rootView)
let view = UIView(frame: CGRect(origin: .init(x: 25, y: 25),
@zenangst
zenangst / Example2.swift
Created February 26, 2018 20:06
How scroll views work on macOS - Example 2
import Cocoa
import PlaygroundSupport
class View: NSView {
override var isFlipped: Bool { return true }
}
let subviewFrame = CGRect(origin: .zero,
size: CGSize(width: 320, height: 640 * 4))
let gradient = CAGradientLayer()
@zenangst
zenangst / Example1.swift
Created February 26, 2018 19:58
How scroll views work on macOS - Example 1
import Cocoa
import PlaygroundSupport
let subviewFrame = CGRect(origin: .zero,
size: CGSize(width: 320, height: 640 * 4))
let gradient = CAGradientLayer()
gradient.colors = [
NSColor.blue.withAlphaComponent(0.2).cgColor,
NSColor.blue.withAlphaComponent(0.4).cgColor
]
@zenangst
zenangst / Example3.swift
Created February 21, 2018 17:59
How frames work on macOS - Example 3
import Cocoa
class ContainerView: ColorView {
override var isFlipped: Bool { return true }
}
class ColorView: NSView {
required init(frame: CGRect, color: NSColor) {
super.init(frame: frame)
wantsLayer = true
@zenangst
zenangst / Example2.swift
Created February 21, 2018 17:46
How frames work on macOS - Example 2
import Cocoa
class ContainerView: ColorView {
override var isFlipped: Bool { return true }
}
class ColorView: NSView {
required init(frame: CGRect, color: NSColor) {
super.init(frame: frame)
wantsLayer = true