Skip to content

Instantly share code, notes, and snippets.

View hanawat's full-sized avatar
👁️
eagle‐eyed

hanawat

👁️
eagle‐eyed
View GitHub Profile
@hanawat
hanawat / UIView+BreakedLayout.swift
Created November 28, 2019 06:05
Swizzlie a process to warn of breaking autolayout.
import UIKit
extension UIView {
/// Swizzlie a process to warn of breaking autolayout.
static func swizzleBreakedLayoutWarning() {
let anyClass: AnyClass = UIView.self
let originalSelector = Selector(("engine:willBreakConstraint:dueToMutuallyExclusiveConstraints:"))
let swizzledSelector = #selector(swizzledEngine(_:willBreak:dueTo:))
guard let originalMethod = class_getInstanceMethod(anyClass, originalSelector),
@hanawat
hanawat / ColorButton.swift
Created April 16, 2019 05:53
Selectable Color Button
import UIKit
/// The Selectable Color Button
class ColorButton: UIButton {
/// Highlighted Background Color
@IBInspectable var highlightedColor: UIColor?
/// Selected Background Color
@IBInspectable var selectedColor: UIColor?
@hanawat
hanawat / file0.txt
Last active June 11, 2018 23:33
What’s New in Swift4.2 まとめ ref: https://qiita.com/hanawat/items/4605f9e357c8794b58d7
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
@hanawat
hanawat / file0.swift
Last active August 23, 2018 23:23
Swift4.0でDictionaryが大幅にパワーアップした ref: https://qiita.com/hanawat/items/341a6f7843f4e19780b5
let touples = [("Apple", 1), ("Orange", 2), ("Grape", 3)]
// ["Grape": 3, "Orange": 2, "Apple": 1]
let dictionary = Dictionary(uniqueKeysWithValues: touples)
struct Person {
let name: String
let age: Int
}
extension Person {
class Helper: NSObject, NSCoding {
@hanawat
hanawat / file0.swift
Last active February 4, 2017 07:26
Swift EvolutionのAcceptedステータスまとめ (2017.1.27) - Protocol-oriented integers, Permit where clauses to constrain associated types, ...etc ref: http://qiita.com/hanawat/items/6e76d958a22b6e77d6ea
struct FooFooFooFooFoo {
static func bar() { }
func baz() {
FooFooFooFooFoo.bar() // Before
type(of: self).bar() // Before
Self.bar() // After
}
}
@hanawat
hanawat / file0.swift
Created September 27, 2016 23:34
iOS10.1でApple MusicのためのAPIが追加されたので試す ref: http://qiita.com/hanawat/items/c900cefcefdadb9b7283
player.setQueueWithStoreIDs(storeIds)
@hanawat
hanawat / Podfile
Created June 26, 2016 11:03
CodeSign error: code signing is required for product type 'Framework' in SDK 'iOS X.X' の対処法 ref: http://qiita.com/hanawat/items/a22cdf6a33d2bc9b08d3
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end
@hanawat
hanawat / CityAndAlian.swift
Last active April 2, 2016 11:45
Protcol can be handled as the type. 👽
import Foundation
protocol Personal {
var name: String { get }
init(name: String)
func sayHelloTo(person: Personal)
}
@hanawat
hanawat / MapViewController.swift
Created March 30, 2016 02:47
iOS9.3で追加されたMKLocalSearchCompleterを試す ref: http://qiita.com/hanawat/items/1f3f3c277a8f2c4b07d2
override func viewDidLoad() {
super.viewDidLoad()
let search = MKLocalSearch(request: request)
search.startWithCompletionHandler { response, error in
response?.mapItems.forEach { item in
let point = MKPointAnnotation()
point.coordinate = item.placemark.coordinate