diff --git a/Source/ActionButton.swift b/Source/ActionButton.swift index 5f84fdc..6056541 100755 --- a/Source/ActionButton.swift +++ b/Source/ActionButton.swift @@ -39,6 +39,28 @@ public class ActionButton: NSObject { } } + public var bottomSpacing: CGFloat { + get { + return bottomSpacingConstraints.first!.constant + } + set { + bottomSpacingConstraints.first!.constant = newValue + self.parentView.updateConstraintsIfNeeded() + self.parentView.layoutIfNeeded() + } + } + + public var trailingSpacing: CGFloat { + get { + return trailingSpacingConstraints.first!.constant + } + set { + trailingSpacingConstraints.first!.constant = newValue + self.parentView.updateConstraintsIfNeeded() + self.parentView.layoutIfNeeded() + } + } + /// The button's background color : set default color public var backgroundColorSelected: UIColor = UIColor(red: 238.0/255.0, green: 130.0/255.0, blue: 34.0/255.0, alpha:1.0) @@ -140,11 +162,11 @@ public class ActionButton: NSObject { let height = NSLayoutConstraint.constraintsWithVisualFormat("V:[floatButton(\(floatButtonRadius))]", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: views) self.floatButton.addConstraints(width) self.floatButton.addConstraints(height) - - let trailingSpacing = NSLayoutConstraint.constraintsWithVisualFormat("V:[floatButton]-15-|", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: views) - let bottomSpacing = NSLayoutConstraint.constraintsWithVisualFormat("H:[floatButton]-15-|", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: views) - self.parentView.addConstraints(trailingSpacing) - self.parentView.addConstraints(bottomSpacing) + + self.bottomSpacingConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:[floatButton]-15-|", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: views) + self.trailingSpacingConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:[floatButton]-15-|", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: views) + self.parentView.addConstraints(trailingSpacingConstraints) + self.parentView.addConstraints(bottomSpacingConstraints) } //MARK: - Button Actions Methods