Swift中lazy懒加载

/// 1.
    lazy var navigationBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: UIScreen.cz_screenWidth(), height: 64))
 /// 2.
    lazy var navItem = UINavigationItem()
///3.
lazy var bundle: Bundle = {
        let path = Bundle.main.pathForResource("HMEmoticon.bundle", ofType: nil)
        
        return Bundle(path: path!)!
    }()
///4.
    lazy var emoticonView: CZEmoticonInputView = CZEmoticonInputView.inputView { [weak self] (emoticon) in

        self?.textView.insertEmoticon(em: emoticon)
    }
///5.
 private lazy var composeButton: UIButton = UIButton.cz_imageButton(
        "tabbar_compose_icon_add",
        backgroundImageName: "tabbar_compose_button")

你可能感兴趣的:(Swift中lazy懒加载)