From df2b47507a61bb087ab81fcfd4220fe6ea03326b Mon Sep 17 00:00:00 2001 From: Alexsandersky Date: Sun, 6 Mar 2016 16:51:53 +0400 Subject: [PATCH] I made customCloseButton private(set) that another developer can to set NSLayoutConstraint --- SKPhotoBrowser/SKPhotoBrowser.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/SKPhotoBrowser/SKPhotoBrowser.swift b/SKPhotoBrowser/SKPhotoBrowser.swift index 9f3cdb4..13db3bd 100644 --- a/SKPhotoBrowser/SKPhotoBrowser.swift +++ b/SKPhotoBrowser/SKPhotoBrowser.swift @@ -62,11 +62,12 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate { private var closeButtonHideFrame: CGRect! //= CGRect(x: 5, y: -20, width: 44, height: 44) // custom close button - private var customCloseButton: UIButton! + private(set) var customCloseButton: UIButton! public var customCloseButtonShowFrame: CGRect! public var customCloseButtonHideFrame: CGRect! public var customCloseButtonImage: UIImage! public var customCloseButtonEdgeInsets: UIEdgeInsets! + public var customCloseButtonConstraints: [NSLayoutConstraint]! private var deleteButton: UIButton! private var deleteButtonShowFrame: CGRect! //= CGRect(x: UIScreen.mainScreen().bounds.size.width - 44 - 5, y: 5, width: 44, height: 44) @@ -316,20 +317,24 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate { customCloseButton = UIButton(type: .Custom) customCloseButton.addTarget(self, action: "closeButtonPressed:", forControlEvents: .TouchUpInside) customCloseButton.backgroundColor = .clearColor() + // If another developer has not set their values if customCloseButtonImage != nil { customCloseButton.setImage(customCloseButtonImage, forState: .Normal) } else { customCloseButton.setImage(closeImage, forState: .Normal) } - // If another developer has not set their values if customCloseButtonShowFrame == nil && customCloseButtonHideFrame == nil { customCloseButtonShowFrame = CGRect(x: 5, y: 5, width: 44, height: 44) customCloseButtonHideFrame = CGRect(x: 5, y: -20, width: 44, height: 44) } if customCloseButtonEdgeInsets != nil { customCloseButton.imageEdgeInsets = customCloseButtonEdgeInsets + } else { + customCloseButton.imageEdgeInsets = UIEdgeInsets(top: 15.25, left: 15.25, bottom: 15.25, right: 15.25) + } + if customCloseButtonConstraints != nil { + customCloseButton.addConstraints(customCloseButtonConstraints) } - customCloseButton.alpha = 0.0 view.addSubview(customCloseButton) } }