Skip to content

Instantly share code, notes, and snippets.

View ha1f's full-sized avatar

はるふ ha1f

View GitHub Profile
//
// Rgba.swift
// ha1f-chat
//
// Created by ST20591 on 2017/07/19.
// Copyright © 2017年 ha1f. All rights reserved.
//
import UIKit
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] = [
extension Dictionary {
func duplicated() -> Dictionary<Key, Value> {
return reduce(into: [Key: Value]()) { (dict, item) in
dict[item.key] = item.value
}
}
}
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
class History<T> {
// MARK: Properties
private var _undoStack: [T] = []
private var _redoStack: [T] = []
private var _current: T
// MARK: Getter, Setter
/// 中心に画像を描画する
class RotatableImageView: UIView {
var image: UIImage? {
didSet {
setNeedsDisplay()
}
}
var angle: CGFloat = 0.0
var scale: CGFloat = 1.0
var translateX: CGFloat = 0.0
// 案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, *) {
//
// SafeAreaLayoutGuideCompatible.swift
//
// Created by はるふ on 2017/12/21.
// Copyright © 2017年 ha1f. All rights reserved.
//
import UIKit
import Foundation
protocol Alphabet {
func accept(_ visitor: AlphabetVisitor)
}
class A {
let aProperty = "A"
}
import Foundation
protocol Alphabet {
func compositeAction()
}
class A {
let aProperty = "A"
}