-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathConstraint.swift
51 lines (35 loc) · 1.57 KB
/
Constraint.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Constraint.swift
// KSFormGenerator
//
// Created by Abhimanyu on 01/04/17.
// Copyright © 2017 Konstant. All rights reserved.
import Foundation
import UIKit
public struct C{
//set any constraint
static func set(item:AnyObject,
attri:NSLayoutAttribute,
relatedBy: NSLayoutRelation = .equal,
toItem:AnyObject? = nil,
attribute:NSLayoutAttribute = .notAnAttribute,
multiplier:CGFloat = 1,
constant:CGFloat = 0,
viewMain:AnyObject){
let any:NSLayoutConstraint = NSLayoutConstraint.init(item: item, attribute: attri, relatedBy: relatedBy, toItem: toItem, attribute: attribute, multiplier: multiplier, constant: constant)
viewMain.addConstraint(any)
}
//get any constraint
static func get(item:AnyObject,
attri:NSLayoutAttribute,
relatedBy: NSLayoutRelation = .equal,
toItem:AnyObject? = nil,
attribute:NSLayoutAttribute = .notAnAttribute,
multiplier:CGFloat = 1,
constant:CGFloat = 0,
viewMain:AnyObject)->NSLayoutConstraint{
let any:NSLayoutConstraint = NSLayoutConstraint.init(item: item, attribute: attri, relatedBy: relatedBy, toItem: toItem, attribute: attribute, multiplier: multiplier, constant: constant)
viewMain.addConstraint(any)
return any
}
}