99import Foundation
1010
1111public enum CDAlertViewType {
12- case error, warning, success, notification, alarm, custom( image: UIImage )
12+ case error, warning, success, notification, alarm, custom( image: UIImage ) , noImage
13+
14+ // This is needed because we can't do a comparison of enums
15+ // if it has an associated value.
16+ func hasImage( ) -> Bool {
17+ switch self {
18+ case . noImage:
19+ return false
20+ default :
21+ return true
22+ }
23+ }
1324}
1425
1526fileprivate protocol CDAlertViewActionDelegate : class {
@@ -525,11 +536,15 @@ open class CDAlertView: UIView {
525536 private func createHeaderView( ) {
526537 headerView = CDAlertHeaderView ( type: type, isIconFilled: isHeaderIconFilled)
527538 headerView. backgroundColor = UIColor . clear
528- headerView. hasShadow = hasShadow
529539 headerView. hasRoundCorners = hasRoundCorners
530540 headerView. alertBackgroundColor = alertBackgroundColor
531- headerView. circleFillColor = circleFillColor
532- if circleFillColor == . clear {
541+ if type. hasImage ( ) == true {
542+ headerView. circleFillColor = circleFillColor
543+ headerView. hasShadow = hasShadow
544+ }
545+ else {
546+ headerView. hasShadow = false
547+ headerView. circleFillColor = . clear
533548 headerHeight = constants. headerHeightWithoutCircle
534549 }
535550 popupView. addSubview ( headerView)
@@ -553,9 +568,9 @@ open class CDAlertView: UIView {
553568 height: height) ,
554569 byRoundingCorners: [ . bottomLeft, . bottomRight] ,
555570 cornerRadii: CGSize ( width: 8.0 , height: 8.0 ) )
556- let roundLayer = CAShapeLayer ( )
557- roundLayer. path = roundCornersPath. cgPath
558571 if hasRoundCorners == true {
572+ let roundLayer = CAShapeLayer ( )
573+ roundLayer. path = roundCornersPath. cgPath
559574 buttonView. layer. mask = roundLayer
560575 }
561576 popupView. addSubview ( buttonView)
0 commit comments