原来-(id)init{
self = [[[NSBundle mainBundle] loadNibNamed:@"ViewBtnWishList" owner:0 options:nil] objectAtIndex:0];
return self;
}
swift
extension UIView {
class func loadFromNibNamed(nibNamed: String, bundle : NSBundle = NSBundle.mainBundle()) -> UIView! {
return UINib(nibName: nibNamed, bundle: bundle).instantiateWithOwner(nil, options: nil)[0] as? UIView
}
}
本文介绍如何使用Swift在iOS应用中从XIB文件加载UIView。通过UINib实例化UIView,并提供了一个具体的实现方法。
2128

被折叠的 条评论
为什么被折叠?



