Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class videoCell:UICollectionViewCell
- {
- override init(frame: CGRect) {
- super.init(frame: frame)
- setUpViews()
- }
- let titlelabel : UILabel =
- {
- var label = UILabel()
- label.backgroundColor = UIColor.brown
- label.translatesAutoresizingMaskIntoConstraints = false
- return label
- }()
- func setUpViews()
- {
- addSubview(titlelabel)
- addConstraint(NSLayoutConstraint(item: titlelabel, attribute:.top, relatedBy: .equal, toItem: thumbNailImageView, attribute: .bottom, multiplier: 1, constant: 8))
- addConstraint(NSLayoutConstraint(item: titlelabel, attribute:.left, relatedBy: .equal, toItem: thumbNailImageView, attribute: .right, multiplier: 1, constant: 8))
- addConstraint(NSLayoutConstraint(item: titlelabel, attribute: .right, relatedBy: .equal, toItem: thumbNailImageView, attribute: .right, multiplier: 1, constant: 0))
- addConstraintsWithFormat(format: "V:[v0(20)]", views:titlelabel)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
- extension UIView
- {
- func addConstraintsWithFormat(format:String,views:UIView...)
- {
- var allViews = [String:UIView]()
- for data in 0...views.count-1
- {
- let key = "v(data)"
- allViews[key] = views[data]
- }
- addConstraints(NSLayoutConstraint.constraints(withVisualFormat: format, options: NSLayoutFormatOptions(), metrics: nil, views: allViews))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement