通讯录

let kScreenWidth = UIScreen.main.bounds.size.width

class ViewController: UIViewController {

var contacter:Contacter!

var nameLabel:UILabel?

var phoneLabel:UILabel?

var ageLabel:UILabel?

var emailLabel:UILabel?

override func viewDidLoad() {

super.viewDidLoad()

self.setupSubviews()

nameLabel?.text = contacter.name

phoneLabel?.text = contacter.phone

ageLabel?.text = "\(contacter.age!)"

emailLabel?.text = contacter.email

}

func setupSubviews() {

nameLabel = UILabel(frame: CGRect(x: 40, y: 150, width: kScreenWidth - 80, height: 40))

nameLabel?.backgroundColor = #colorLiteral(red: 1, green: 0.8293197434, blue: 0.7869954458, alpha: 1)

nameLabel?.textAlignment = .center

self.view.addSubview(nameLabel!)

phoneLabel = UILabel(frame: CGRect(x: 40, y: 200, width: kScreenWidth - 80, height: 40))

phoneLabel?.backgroundColor = #colorLiteral(red: 1, green: 0.8293197434, blue: 0.7869954458, alpha: 1)

phoneLabel?.textAlignment = .center

self.view.addSubview(phoneLabel!)

ageLabel = UILabel(frame: CGRect(x: 40, y: 250, width: kScreenWidth - 80, height: 40))

ageLabel?.backgroundColor = #colorLiteral(red: 1, green: 0.8293197434, blue: 0.7869954458, alpha: 1)

ageLabel?.textAlignment = .center

self.view.addSubview(ageLabel!)

emailLabel = UILabel(frame: CGRect(x: 40, y: 300, width: kScreenWidth - 80, height: 40))

emailLabel?.backgroundColor = #colorLiteral(red: 1, green: 0.8293197434, blue: 0.7869954458, alpha: 1)

emailLabel?.textAlignment = .center

self.view.addSubview(emailLabel!)

}

override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

/*

// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

// Get the new view controller using segue.destinationViewController.

// Pass the selected object to the new view controller.

}

*/

}

你可能感兴趣的:(通讯录)