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
// | |
// Rgba.swift | |
// ha1f-chat | |
// | |
// Created by ST20591 on 2017/07/19. | |
// 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
extension UIImage { | |
/// 文字の画像を生成する。文字は中心に置かれる。 | |
/// | |
/// - parameter text: 文字列 | |
/// - parameter font: フォント | |
/// - parameter textColor: 文字色 | |
/// - parameter imageSize: 生成する画像のサイズ(スクリーンスケール倍される) | |
/// - returns: 生成されたテキスト画像 | |
static func fromText(_ text: String, font: UIFont, textColor: UIColor, imageSize: CGSize) -> UIImage { | |
let attributes: [NSAttributedString.Key: Any] = [ |
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 Dictionary { | |
func duplicated() -> Dictionary<Key, Value> { | |
return reduce(into: [Key: Value]()) { (dict, item) in | |
dict[item.key] = item.value | |
} | |
} | |
} |
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 UIViewController { | |
private class ExtendedBottomView: UIView { } | |
/// Create bottom View which covers from bottom of the screen to the | |
/// bottom edge of the bottomAccessoryView. | |
/// (useful on iPhone X only) | |
/// Make sure not to call more than once (typically, on viewDidLoad), | |
/// and bottomAccessoryView has added as subview. | |
/// | |
/// - parameter bottomAccessoryView: a target View to decide the |
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 | |
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
// 案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
// | |
// 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
import Foundation | |
protocol Alphabet { | |
func accept(_ visitor: AlphabetVisitor) | |
} | |
class A { | |
let aProperty = "A" | |
} |
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 | |
protocol Alphabet { | |
func compositeAction() | |
} | |
class A { | |
let aProperty = "A" | |
} |