Skip to content

Commit 544a18a

Browse files
authored
Merge pull request #1 from alexsun/master
增加能自动推断类型的 loadFromNib 方法
2 parents 27dc800 + c79cfac commit 544a18a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CRBoostSwift/Classes/UIKit+CRBoost.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ extension UIView {
178178
let view = nib![0]
179179
return view as! T
180180
}
181+
182+
@discardableResult
183+
public class func loadFromNib(nibName: String) -> Self {
184+
let nib = Bundle.main.loadNibNamed(nibName, owner: self, options: [:])
185+
let view = nib![0]
186+
return view as! Self
187+
}
181188

182189
@discardableResult
183190
public func topLayerSubview(_ tag: Int) -> UIView? {

0 commit comments

Comments
 (0)