Skip to content

Commit

Permalink
% If the circle color is clear, i.e. don’t show it we shrink the head…
Browse files Browse the repository at this point in the history
…er to make it look good
  • Loading branch information
Scott Gruby authored and candostdagdeviren committed Mar 14, 2018
1 parent 628db4e commit 2f8f6d6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions CDAlertView/Classes/CDAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ open class CDAlertView: UIView {

private struct CDAlertViewConstants {
let headerHeight: CGFloat = 56
let headerHeightWithoutCircle: CGFloat = 30
let activeVelocity: CGFloat = 150
let minVelocity: CGFloat = 300
let separatorThickness: CGFloat = 1.0 / UIScreen.main.scale
Expand All @@ -254,6 +255,7 @@ open class CDAlertView: UIView {
private var textField: UITextField = UITextField(frame: .zero)
private var type: CDAlertViewType!
weak private var hideTimer: Timer!
public var headerHeight: CGFloat = CDAlertViewConstants().headerHeight

private lazy var actions: [CDAlertViewAction] = [CDAlertViewAction]()

Expand Down Expand Up @@ -285,9 +287,9 @@ open class CDAlertView: UIView {
popupView.layer.masksToBounds = false
let path = UIBezierPath()
path.move(to: CGPoint(x: 0.0, y: popupView.bounds.size.height))
path.addLine(to: CGPoint(x: 0, y: constants.headerHeight))
path.addLine(to: CGPoint(x: 0, y: headerHeight))
path.addLine(to: CGPoint(x: popupView.bounds.size.width,
y: CGFloat(constants.headerHeight - 5)))
y: CGFloat(headerHeight - 5)))
path.addLine(to: CGPoint(x: popupView.bounds.size.width,
y: popupView.bounds.size.height))
path.close()
Expand Down Expand Up @@ -527,12 +529,15 @@ open class CDAlertView: UIView {
headerView.hasRoundCorners = hasRoundCorners
headerView.alertBackgroundColor = alertBackgroundColor
headerView.circleFillColor = circleFillColor
if circleFillColor == .clear {
headerHeight = constants.headerHeightWithoutCircle
}
popupView.addSubview(headerView)
headerView.translatesAutoresizingMaskIntoConstraints = false
headerView.cd_alignTopToParent(with: 0)
headerView.cd_alignLeftToParent(with: 0)
headerView.cd_alignRightToParent(with: 0)
headerView.cd_setHeight(constants.headerHeight)
headerView.cd_setHeight(headerHeight)
}

private func createButtonContainer() {
Expand Down

0 comments on commit 2f8f6d6

Please sign in to comment.