Skip to content

Instantly share code, notes, and snippets.

View bielikb's full-sized avatar

Boris Bielik bielikb

View GitHub Profile
@bielikb
bielikb / Property Wrapper
Last active September 13, 2019 23:51
Use Autolayout
@propertyWrapper
public struct UseAutoLayout<T: UIView> {
var value: T
public var wrappedValue: T {
get { return value }
set { self.value.translatesAutoresizingMaskIntoConstraints = false }
}
public init(wrappedValue: T) {
@bielikb
bielikb / UIView.swift
Last active April 20, 2018 12:07
Extension to load uiview from nib
extension UIView {
///
/// Loads a view from nib.
///
/// Please note that if you are assigning directly to an optinonal or unwrapped
/// optional you have to specify `name` of the nib.
///
class func loadFromNib<T>(_ name: String = String(describing: T.self), owner: AnyObject? = nil, options: [AnyHashable: Any]? = nil, bundle: Bundle? = Bundle.main) -> T {
return UINib(nibName: name, bundle: bundle).instantiate(withOwner: owner, options: options).first as! T
}
@bielikb
bielikb / UIDevice.swift
Last active December 7, 2017 19:25
UIDevice extension with model type - iPhone X support
extension UIDevice {
enum UIDeviceModelType : Equatable {
///iPhoneX
case iPhoneX
///Other models
case other(model: String)