美文网首页
swift 通过protocol快速写view

swift 通过protocol快速写view

作者: 五角 | 来源:发表于2020-07-22 18:29 被阅读0次
import UIKit

protocol NibLoadable {}

extension NibLoadable where Self: UIView {
    static func loadViewFromNib() -> Self {
        return Bundle.main.loadNibNamed("\(self)", owner: nil, options: nil)?.first as! Self
    }
}

相关文章

网友评论

      本文标题:swift 通过protocol快速写view

      本文链接:https://www.haomeiwen.com/subject/drvtlktx.html