Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kButtonHeight issue and opened the labelTitle variable to editting #466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions SCLAlertView/SCLAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -258,6 +259,8 @@ open class SCLAlertView: UIViewController {
self.buttonsLayout = buttonsLayout

self.activityIndicatorStyle = activityIndicatorStyle

self.kButtonBottomMargin = kButtonBottomMargin

self.textViewAlignment = textViewAlignment
}
Expand Down Expand Up @@ -300,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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down