Skip to content

Commit

Permalink
Fixing issue vikmeup#439 - set gradient background color
Browse files Browse the repository at this point in the history
  • Loading branch information
spneshaei committed Jul 7, 2021
1 parent f08ec93 commit aef1e3b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions SCLAlertView/SCLAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ open class SCLAlertView: UIViewController {
let contentViewBorderColor: UIColor
let titleColor: UIColor
let subTitleColor: UIColor
let gradientColors: [UIColor]

let margin: Margin
/// Margin for SCLAlertView.
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, gradientColors: [UIColor] = []) {

self.kDefaultShadowOpacity = kDefaultShadowOpacity
self.kCircleTopPosition = kCircleTopPosition
Expand Down Expand Up @@ -260,6 +261,8 @@ open class SCLAlertView: UIViewController {
self.activityIndicatorStyle = activityIndicatorStyle

self.textViewAlignment = textViewAlignment

self.gradientColors = gradientColors
}

mutating func setkWindowHeight(_ kWindowHeight:CGFloat) {
Expand Down Expand Up @@ -343,7 +346,14 @@ open class SCLAlertView: UIViewController {
// Set up main view
view.frame = UIScreen.main.bounds
view.autoresizingMask = [UIView.AutoresizingMask.flexibleHeight, UIView.AutoresizingMask.flexibleWidth]
view.backgroundColor = UIColor(red:0, green:0, blue:0, alpha:appearance.kDefaultShadowOpacity)
if appearance.gradientColors.isEmpty {
view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: appearance.kDefaultShadowOpacity)
} else {
let gradient = CAGradientLayer()
gradient.frame = view.bounds
gradient.colors = appearance.gradientColors
view.layer.insertSublayer(gradient, at: 0)
}
view.addSubview(baseView)
// Base View
baseView.frame = view.frame
Expand Down

0 comments on commit aef1e3b

Please sign in to comment.