Skip to content

Commit

Permalink
Add NibLoadable for UIView
Browse files Browse the repository at this point in the history
  • Loading branch information
corin8823 committed Nov 9, 2015
1 parent 5868d9f commit c673b3c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
17 changes: 12 additions & 5 deletions SwiftyExtensions/UIView+Addtions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ extension UIView {
self.frame.origin.y = y
}

public class func loadNib() -> UIView {
let name = StringFromClass(self)
return NSBundle.mainBundle().loadNibNamed(name, owner: nil, options: nil)[0] as! UIView
}

public func roundedCorrner(radius: CGFloat) {
self.layer.cornerRadius = radius
self.clipsToBounds = true
Expand Down Expand Up @@ -91,3 +86,15 @@ extension UIView {
return false
}
}

extension UIView: NibLoadable {}

protocol NibLoadable{}

extension NibLoadable {

static func loadNib() -> Self {
let className = StringFromType(Self)
return NSBundle.mainBundle().loadNibNamed(className, owner: nil, options: nil)[0] as! Self
}
}
14 changes: 0 additions & 14 deletions SwiftyExtensions/UIViewController+UIStoryBoard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@

import UIKit

extension UIViewController {

public class func initialLoadStoryboard() -> UIViewController {
let storyboard = UIStoryboard(name: StringFromClass(self), bundle: nil)
return storyboard.instantiateInitialViewController()!
}

public class func loadStoryboard() -> UIViewController {
let className = StringFromClass(self)
let storyboard = UIStoryboard(name: className, bundle: nil)
return storyboard.instantiateViewControllerWithIdentifier(className)
}
}

extension UIViewController: StoryboardLoadable {}

protocol StoryboardLoadable {}
Expand Down

0 comments on commit c673b3c

Please sign in to comment.