Skip to content

Commit

Permalink
Exposed basic shadow appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
mwfire committed Jun 25, 2016
1 parent 7aeee5c commit 9969a8e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Example/Tests/AppearanceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class AppearanceTests: XCTestCase {
XCTAssertEqual(view.messageColor, UIColor(white: 0.6, alpha: 1))
XCTAssertTrue (view.messageTextAlignment == .Center)
XCTAssertEqual(view.cornerRadius, 4)
XCTAssertTrue(view.shadowEnabled)
XCTAssertEqual(view.shadowColor, UIColor.blackColor())

// Button defaults
let defaultButton = DefaultButton(title: "", action: nil)
Expand Down Expand Up @@ -64,6 +66,8 @@ class AppearanceTests: XCTestCase {
pv.messageColor = UIColor.redColor()
pv.messageTextAlignment = .Right
pv.cornerRadius = 10
pv.shadowEnabled = false
pv.shadowColor = UIColor.greenColor()

// Customize overlay appearance
let ov = PopupDialogOverlayView.appearance()
Expand All @@ -88,6 +92,8 @@ class AppearanceTests: XCTestCase {
XCTAssertEqual(pv.messageColor, UIColor.redColor())
XCTAssertTrue (pv.messageTextAlignment == .Right)
XCTAssertEqual(pv.cornerRadius, 10)
XCTAssertFalse(pv.shadowEnabled)
XCTAssertEqual(pv.shadowColor, UIColor.greenColor())

// Overlay customized appearance
XCTAssertEqual(ov.color, UIColor.yellowColor())
Expand Down
17 changes: 17 additions & 0 deletions PopupDialog/Classes/PopupDialogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ final public class PopupDialogView: UIView {
}
}

/// Enable / disable shadow rendering
public dynamic var shadowEnabled: Bool {
get { return shadowContainer.layer.shadowRadius > 0 }
set { shadowContainer.layer.shadowRadius = newValue ? 5 : 0 }
}

/// The shadow color
public dynamic var shadowColor: UIColor? {
get {
guard let color = shadowContainer.layer.shadowColor else {
return nil
}
return UIColor(CGColor: color)
}
set { shadowContainer.layer.shadowColor = newValue?.CGColor }
}

// MARK: Views

/// The shadow container is the basic view of the PopupDialog
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ dialogAppearance.messageFont = UIFont.systemFontOfSize(14)
dialogAppearance.messageColor = UIColor(white: 0.6, alpha: 1)
dialogAppearance.messageTextAlignment = .Center
dialogAppearance.cornerRadius = 4
dialogAppearance.shadowEnabled = true
dialogAppearance.shadowColor = UIColor.blackColor()

// Popup Dialog Overlay View Appearance Settings
let overlayAppearance = PopupDialogOverlayView.appearance()
Expand Down Expand Up @@ -193,7 +195,7 @@ pod 'PopupDialog', '~> 0.1'

## Changelog

* **0.1.3** Big screen support
* **0.1.3** Big screen support<br>Exposed basic shadow appearance
* **0.1.2** Exposed blur and overlay appearance
* **0.1.1** Added themeing example
* **0.1.0** Intitial version
Expand Down

0 comments on commit 9969a8e

Please sign in to comment.