Last active
September 5, 2016 18:20
-
-
Save richy486/b95786706276fd58c4dfe811401090a7 to your computer and use it in GitHub Desktop.
UIView+ConstraintsHelper.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIView+ConstraintsHelper.swift | |
// | |
// Created by Richard Adem on 5/17/16. | |
// Copyright © 2016 Richard Adem. All rights reserved. | |
// | |
import UIKit | |
struct VFLManager { | |
var options:NSLayoutFormatOptions | |
var metrics:[String : AnyObject]? | |
var views:[String : AnyObject] | |
var view:UIView | |
func add(vflString:String) { | |
view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: vflString | |
, options: options | |
, metrics: metrics | |
, views: views)) | |
} | |
} | |
extension UIView { | |
func setVFLWithOptions(options opts: NSLayoutFormatOptions | |
, metrics: [String : AnyObject]? | |
, views: [String : AnyObject] | |
, block: (_:VFLManager) -> ()){ | |
let vflManager = VFLManager(options: opts, metrics: metrics, views: views, view: self) | |
block(vflManager) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment