From 86ceb40056ee100ae74664919cb179d72b9fcc10 Mon Sep 17 00:00:00 2001 From: Adam Lee Date: Tue, 25 Feb 2020 14:12:48 +0000 Subject: [PATCH 1/2] Added kBottomMargin for vertically stacked buttons --- SCLAlertView/SCLAlertView.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/SCLAlertView/SCLAlertView.swift b/SCLAlertView/SCLAlertView.swift index 8f0e413..5e59004 100644 --- a/SCLAlertView/SCLAlertView.swift +++ b/SCLAlertView/SCLAlertView.swift @@ -154,7 +154,8 @@ open class SCLAlertView: UIViewController { let kTextFieldHeight: CGFloat let kTextViewdHeight: CGFloat let kButtonHeight: CGFloat - let circleBackgroundColor: UIColor + let kButtonBottomMargin: CGFloat + let circleBackgroundColor: UIColor let contentViewColor: UIColor let contentViewBorderColor: UIColor let titleColor: UIColor @@ -218,7 +219,7 @@ open class SCLAlertView: UIViewController { // Activity indicator var activityIndicatorStyle: UIActivityIndicatorView.Style - public init(kDefaultShadowOpacity: CGFloat = 0.7, kCircleTopPosition: CGFloat = 0.0, kCircleBackgroundTopPosition: CGFloat = 6.0, kCircleHeight: CGFloat = 56.0, kCircleIconHeight: CGFloat = 20.0, kTitleHeight:CGFloat = 25.0, kWindowWidth: CGFloat = 240.0, kWindowHeight: CGFloat = 178.0, kTextHeight: CGFloat = 90.0, kTextFieldHeight: CGFloat = 30.0, kTextViewdHeight: CGFloat = 80.0, kButtonHeight: CGFloat = 35.0, kTitleFont: UIFont = UIFont.systemFont(ofSize: 20), kTitleMinimumScaleFactor: CGFloat = 1.0, kTextFont: UIFont = UIFont.systemFont(ofSize: 14), kButtonFont: UIFont = UIFont.boldSystemFont(ofSize: 14), showCloseButton: Bool = true, showCircularIcon: Bool = true, shouldAutoDismiss: Bool = true, contentViewCornerRadius: CGFloat = 5.0, fieldCornerRadius: CGFloat = 3.0, buttonCornerRadius: CGFloat = 3.0, hideWhenBackgroundViewIsTapped: Bool = false, circleBackgroundColor: UIColor = UIColor.white, contentViewColor: UIColor = UIColorFromRGB(0xFFFFFF), contentViewBorderColor: UIColor = UIColorFromRGB(0xCCCCCC), titleColor: UIColor = UIColorFromRGB(0x4D4D4D), subTitleColor: UIColor = UIColorFromRGB(0x4D4D4D), margin: Margin = Margin(), dynamicAnimatorActive: Bool = false, disableTapGesture: Bool = false, buttonsLayout: SCLAlertButtonLayout = .vertical, activityIndicatorStyle: UIActivityIndicatorView.Style = .white, textViewAlignment: NSTextAlignment = .center) { + public init(kDefaultShadowOpacity: CGFloat = 0.7, kCircleTopPosition: CGFloat = 0.0, kCircleBackgroundTopPosition: CGFloat = 6.0, kCircleHeight: CGFloat = 56.0, kCircleIconHeight: CGFloat = 20.0, kTitleHeight:CGFloat = 25.0, kWindowWidth: CGFloat = 240.0, kWindowHeight: CGFloat = 178.0, kTextHeight: CGFloat = 90.0, kTextFieldHeight: CGFloat = 30.0, kTextViewdHeight: CGFloat = 80.0, kButtonHeight: CGFloat = 35.0, kTitleFont: UIFont = UIFont.systemFont(ofSize: 20), kTitleMinimumScaleFactor: CGFloat = 1.0, kTextFont: UIFont = UIFont.systemFont(ofSize: 14), kButtonFont: UIFont = UIFont.boldSystemFont(ofSize: 14), showCloseButton: Bool = true, showCircularIcon: Bool = true, shouldAutoDismiss: Bool = true, contentViewCornerRadius: CGFloat = 5.0, fieldCornerRadius: CGFloat = 3.0, buttonCornerRadius: CGFloat = 3.0, hideWhenBackgroundViewIsTapped: Bool = false, circleBackgroundColor: UIColor = UIColor.white, contentViewColor: UIColor = UIColorFromRGB(0xFFFFFF), contentViewBorderColor: UIColor = UIColorFromRGB(0xCCCCCC), titleColor: UIColor = UIColorFromRGB(0x4D4D4D), subTitleColor: UIColor = UIColorFromRGB(0x4D4D4D), margin: Margin = Margin(), dynamicAnimatorActive: Bool = false, disableTapGesture: Bool = false, buttonsLayout: SCLAlertButtonLayout = .vertical, activityIndicatorStyle: UIActivityIndicatorView.Style = .white, textViewAlignment: NSTextAlignment = .center, kButtonBottomMargin : CGFloat = 0) { self.kDefaultShadowOpacity = kDefaultShadowOpacity self.kCircleTopPosition = kCircleTopPosition @@ -258,6 +259,8 @@ open class SCLAlertView: UIViewController { self.buttonsLayout = buttonsLayout self.activityIndicatorStyle = activityIndicatorStyle + + self.kButtonBottomMargin = kButtonBottomMargin self.textViewAlignment = textViewAlignment } @@ -424,10 +427,10 @@ open class SCLAlertView: UIViewController { let buttonMargin = appearance.margin.buttonSpacing let textFieldMargin = appearance.margin.textFieldSpacing if appearance.buttonsLayout == .vertical { - consumedHeight += appearance.kButtonHeight * CGFloat(buttons.count) + consumedHeight += (appearance.kButtonHeight * CGFloat(buttons.count)) + appearance.kButtonBottomMargin consumedHeight += buttonMargin * (CGFloat(buttons.count) - 1) } else { - consumedHeight += appearance.kButtonHeight + consumedHeight += appearance.kButtonHeight + appearance.kButtonBottomMargin } consumedHeight += (appearance.kTextFieldHeight + textFieldMargin) * CGFloat(inputs.count) consumedHeight += appearance.kTextViewdHeight * CGFloat(input.count) @@ -496,7 +499,7 @@ open class SCLAlertView: UIViewController { for btn in buttons { btn.frame = CGRect(x:buttonX, y:y, width:subViewsWidth, height:appearance.kButtonHeight) btn.layer.cornerRadius = appearance.buttonCornerRadius - y += appearance.kButtonHeight + buttonMargin + y += (appearance.kButtonHeight + buttonMargin) + appearance.kButtonBottomMargin } case .horizontal: let numberOfButton = CGFloat(buttons.count) From 7cbead12ccc42504debeebed1ef1c0dcebbd2637 Mon Sep 17 00:00:00 2001 From: Adam Lee Date: Tue, 25 Feb 2020 14:16:09 +0000 Subject: [PATCH 2/2] labelTitle set as open var This was done to display an error message in the alert --- SCLAlertView/SCLAlertView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SCLAlertView/SCLAlertView.swift b/SCLAlertView/SCLAlertView.swift index 5e59004..a4df1c1 100644 --- a/SCLAlertView/SCLAlertView.swift +++ b/SCLAlertView/SCLAlertView.swift @@ -303,7 +303,7 @@ open class SCLAlertView: UIViewController { // Members declaration var baseView = UIView() - var labelTitle = UILabel() + open var labelTitle = UILabel() var viewText = UITextView() var contentView = UIView() var circleBG = UIView(frame:CGRect(x:0, y:0, width:kCircleHeightBackground, height:kCircleHeightBackground))