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

Shadow style #12

Closed
artemnovichkov opened this issue Jul 12, 2019 · 0 comments
Closed

Shadow style #12

artemnovichkov opened this issue Jul 12, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@artemnovichkov
Copy link
Contributor

Add a style for shadows

import UIKit

open class ShadowStyle {

    public var opacity: CGFloat = 0.0
    public var radius: CGFloat = 0.0
    public var offset: CGSize = .zero
    public var color: UIColor = .clear

    var shadow: NSShadow {
        let shadow = NSShadow()
        shadow.shadowBlurRadius = radius
        shadow.shadowOffset = offset
        shadow.shadowColor = color.withAlphaComponent(opacity)
        return shadow
    }
}

// MARK: - Equatable

extension ShadowStyle: Equatable {
    public static func == (lhs: ShadowStyle, rhs: ShadowStyle) -> Bool {
        return lhs.color == rhs.color &&
               lhs.offset == rhs.offset &&
               lhs.radius == rhs.radius &&
               lhs.opacity == rhs.opacity
    }
}
@artemnovichkov artemnovichkov added the enhancement New feature or request label Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant