Skip to content

Instantly share code, notes, and snippets.

View reyandrey's full-sized avatar

Andrey Fokin reyandrey

  • Saint Petersburg, Russia
View GitHub Profile
@reyandrey
reyandrey / ExtensionViewController.swift
Created July 7, 2019 21:16
Hide keyboard when tapped around
// Put this piece of code anywhere you like
extension UIViewController {
func hideKeyboardWhenTappedAround() {
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard))
tap.cancelsTouchesInView = false
view.addGestureRecognizer(tap)
}
@objc func dismissKeyboard() {
view.endEditing(true)
@reyandrey
reyandrey / ControlPanelView.swift
Created July 7, 2019 18:57
View from XIB Swift Example
import UIKit
import Foundation
@IBDesignable
class ControlPanelView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
setupViews()
}