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

Readme clarification #1

Closed
wtmoose opened this issue Aug 25, 2016 · 1 comment
Closed

Readme clarification #1

wtmoose opened this issue Aug 25, 2016 · 1 comment

Comments

@wtmoose
Copy link

wtmoose commented Aug 25, 2016

This is a handy component, but the following statement doesn't seem accurate:

Normally it's not possible to set a corner radius and a shadow on a UIView subclass. This is because the property clipsToBounds must be set to true for the view to render the rounded corners, which also clips the shadow away.

The following UIView subclass will happily display a corner radius and a drop shadow. Consider clarifying the readme.

class ShadowView: UIView {

    override func awakeFromNib() {
        super.awakeFromNib()
        layer.masksToBounds = false
        layer.cornerRadius = 10.0
        layer.shadowColor = UIColor.blackColor().CGColor
        layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
        layer.shadowRadius = 6.0
        layer.shadowOpacity = 0.4
        updateShadowPath()
    }

    private func updateShadowPath() {
        layer.shadowPath = UIBezierPath(roundedRect: layer.bounds, cornerRadius: layer.cornerRadius).CGPath
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        updateShadowPath()
    }
}
@benboecker
Copy link
Owner

Thanks for the feedback, this really is a much simpler solution. I will use this implementation for the next update and mention you accordingly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants