This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 中心に画像を描画する | |
class RotatableImageView: UIView { | |
var image: UIImage? { | |
didSet { | |
setNeedsDisplay() | |
} | |
} | |
var angle: CGFloat = 0.0 | |
var scale: CGFloat = 1.0 | |
var translateX: CGFloat = 0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// QrCodeGenerator.swift | |
// CoreImageSample | |
// | |
// Created by はるふ on 2017/12/11. | |
// Copyright © 2017年 ha1f. All rights reserved. | |
// | |
import Foundation | |
import CoreImage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PrintingViewController: UIViewController { | |
// Load | |
override func loadView() { | |
super.loadView() | |
print("lifecycle", #function) | |
} | |
override func viewDidLoad() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension UnicodeScalar { | |
/// `a-z{ | |
var isLowerCase: Bool { | |
return value >= 0x61 && value <= 0x7a | |
} | |
/// @A-Z[ | |
var isUpperCase: Bool { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SafeAreaLayoutGuideCompatible.swift | |
// | |
// Created by はるふ on 2017/12/21. | |
// Copyright © 2017年 ha1f. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 案1 | |
extension UIView { | |
/// Returns UILayoutGuide compatible with safeAreaLayoutGuide. | |
/// `.safeAreaLayoutGuide` is available only iOS 11+, but safeAreaLayoutGuide | |
/// should be same as layoutguide of UIView under iOS 11. | |
/// | |
/// - returns safeAreaLayoutGuide or layoutGuide of self | |
func safeLayoutGuideOrSelfLayoutGuide() -> UILayoutGuide { | |
if #available(iOS 11.0, *) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NthTimeLucky.swift | |
// | |
// Created by はるふ on 2018/05/24. | |
// Copyright © 2018年 ha1f. All rights reserved. | |
// | |
import Foundation | |
import RxSwift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
/// CGAffineTransform to apply orientation of the image | |
var orientationTransformer: CGAffineTransform { | |
var transform = CGAffineTransform(translationX: size.width / 2, y: size.height / 2) | |
switch imageOrientation { | |
case .up, .upMirrored: | |
break | |
case .down, .downMirrored: | |
transform = transform.rotated(by: CGFloat.pi) | |
case .left, .leftMirrored: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// import EthereumKit | |
// import Play | |
final class Lets { | |
private let nyanWallet = Wallet("💰") | |
private let nyan = Haruna("🐈") | |
func go(to place: String) { | |
nyan.move(to: place) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class History<T> { | |
// MARK: Properties | |
private var _undoStack: [T] = [] | |
private var _redoStack: [T] = [] | |
private var _current: T | |
// MARK: Getter, Setter | |