Skip to content

farhad1985/Connectable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Connectable

I've written a protocol for connect an uiview to a xib file .

import UIKit

protocol Connectable {}

extension Connectable where Self: UIView {
    func commit() {
        let nib = UINib(nibName: String(describing: Self.self), bundle: nil)
        let views = nib.instantiate(withOwner: self, options: nil)
        guard let view = views.first as? UIView else {return}
        view.frame = bounds
        addSubview(view)
    }
}

you must use this protocol inherit to every UIView.

Releases

No releases published

Packages

No packages published

Languages