Skip to content

Instantly share code, notes, and snippets.

View takehilo's full-sized avatar
🐹
Building iOS apps!

Takehiro Kaneko takehilo

🐹
Building iOS apps!
View GitHub Profile
@takehilo
takehilo / ResizableView.swift
Created March 28, 2019 02:54
Resizable view implementation like rectangles in the markup feature of iOS Photo app
import UIKit
class ResizableRectangle: UIView {
private let borderWidth: CGFloat = 10
private var halfOfBorderWidth: CGFloat { return borderWidth / 2 }
private let topControl = Control(position: .top)
private let upperRightControl = Control(position: .upperRight)
private let rightControl = Control(position: .right)
private let lowerRightControl = Control(position: .lowerRight)
@takehilo
takehilo / MessageSender.swift
Last active February 5, 2019 02:27
iOS設計パターン入門 第3章 MessageSenderの実装例
import UIKit
import PlaygroundSupport
let page = PlaygroundPage.current
page.needsIndefiniteExecution = true
protocol Message {}
struct TextMessage: Message, Decodable {
var text: String?