import UIKit import Foundation class DetailView: UIViewController{ var fullImage:UIImageView? var nameLabel:UILabel? var detailLabel:UILabel?

override  func viewDidLoad() {
    super.viewDidLoad()
    fullImage = UIImageView()
    nameLabel = UILabel()
    detailLabel = UILabel()
    self.view.addSubview(fullImage!)
    self.view.addSubview(nameLabel!)
    self.view.addSubview(detailLabel!)
}

func applyContraints(){
    self.view.addSubview(fullImage!)

 fullImage?.setTranslatesAutoresizingMaskIntoConstraints(false)
 nameLabel?.setTranslatesAutoresizingMaskIntoConstraints(false)
 detailLabel?.setTranslatesAutoresizingMaskIntoConstraints(false)

    var viewsDict:[String:AnyObject!] = ["imageView": fullImage!, "nameLabel": nameLabel!, "detailLabel": detailLabel!]

    var constraints:NSArray

    constraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|-10-[imageView]-10-|",
        options: 0,
        metrics: nil,
        views: viewsDict)
    self.view.addConstraints(constraints)



}

}

Related posts

Recent Viewed