swift开发笔记09

// 类的扩展

public extension UIColor {

    convenience init(r: Int, g:Int, b:Int, a:CGFloat) {

        self.init(red: CGFloat(r)/255, green:CGFloat(g)/255, blue: CGFloat(b)/255, alpha: a)

        

    }

    

    convenience init(hex: Int) {

        self.init(r: (hex & 0xff0000) >> 16, g: (hex & 0xff00)  >> 8, b: (hex & 0xff), a: 1)

    }

}

 

// 参数,带有默认值

    init(name: String, avatarName: String = "bayMax", education: String)

    {

        self.name = name

        self.avatarName = avatarName

        self.education = education

    }

 

// 参数的get方法

    fileprivate var user: FBMeUser {

        get {

            return FBMeUser.init(name: "BayMax", education: "CMU")

        }

    }

//参数的初始化,cell的注册

    private let myTableView: UITableView = {

        let view = UITableView.init(frame: .zero, style: .grouped)

        view.register(CellOne.self,forCellReuseIdentifier: CellOne.indentifier)

        return view

    }()

 

    public static var color: Color{

        return Color()

    }

 

 

 

 

 

 

原文地址:https://www.cnblogs.com/dengchaojie/p/7340038.html