This file contains hidden or 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 ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let gesture = UITapGestureRecognizer() | |
gesture.numberOfTapsRequired = 2 // ここで回数を設定する | |
gesture.rx.event.asSignal() | |
.emit(onNext: { [weak self] _ in | |
// do somthing... |
This file contains hidden or 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
/* | |
before | |
fun asyncLoad(callback: (result: String) -> Unit) { | |
load { result -> | |
callback(result) | |
} | |
} | |
*/ | |
suspend fun asyncLoad(): String = suspendCoroutine { continuation -> |
This file contains hidden or 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
public extension Array { | |
/// Secure access at index. | |
/// | |
/// let array = [1, 2] | |
/// array[safe: 0] // Optional(1) | |
/// array[safe: 1] // Optional(2) | |
/// array[safe: 2] // nil | |
subscript (safe index: Index) -> Element? { | |
return indices.contains(index) ? self[index] : nil |
This file contains hidden or 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 UIKit | |
@IBDesignable class UIPaddingTextField: UITextField { | |
// MARK: Properties | |
@IBInspectable var padding: CGPoint = CGPoint(x: 8.0, y: 0.0) | |
// MARK: Internal Methods | |
override func textRect(forBounds bounds: CGRect) -> CGRect { | |
return bounds.insetBy(dx: self.padding.x, dy: self.padding.y) |
This file contains hidden or 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 UIKit | |
import Photos | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
private func selectFromLibrary() { |
This file contains hidden or 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
@IBOutlet weak var floatingActionButton: UIView! { | |
didSet { | |
floatingActionButton.layer.cornerRadius = floatingActionButton.width / 2.0 | |
floatingActionButton.layer.shadowOpacity = 0.8 | |
floatingActionButton.layer.shadowOffset = CGSize(width: 2.0, height: 2.0) | |
floatingActionButton.layer.shadowColor = UIColor.darkGray.cgColor | |
} | |
} |
This file contains hidden or 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
// buildTypesに応じたgoogle-services.jsonをapp/.へコピー | |
gradle.taskGraph.beforeTask { Task task -> | |
if (task.name ==~ /process.*GoogleServices/) { | |
applicationVariants.all { variant -> | |
if (task.name ==~ /(?i)process${variant.name}GoogleServices/) { | |
copy { | |
from "src/${variant.name}" | |
into "." | |
include "google-services.json" | |
} |
This file contains hidden or 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 RxSwift | |
import RxCocoa | |
class ViewController: UIViewController { | |
@IBOutlet private weak var bottomConstraint: NSLayoutConstraint! | |
private let disposeBag = DisposeBag() | |
override func viewDidLoad() { |
This file contains hidden or 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
/** | |
* カスタムActivityの取得 | |
* 取得できない場合はnull | |
*/ | |
val Activity.rootApplication: RootApplication? | |
get() = (application as? RootApplication) | |
/** | |
* 現在フォーカスされているViewを元にKeyboardを非表示にする | |
*/ |