swift3.0懒加载,自定义构造函数创建
近期在使用swift3.0开发,遇到了不少新的知识,于是想记录,并分享出来:
懒加载:
fileprivate lazy var scrollView : UIScrollView = { let scrollView = UIScrollView() scrollView.showsHorizontalScrollIndicator = false scrollView.scrollsToTop = false scrollView.isPagingEnabled = false scrollView.bounces = false return scrollView }()
自定构造函数:
//自定义构造函数 init(frame: CGRect, titles: [String]) { self.titles = titles super.init(frame: frame) setUi() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }