MengTo / Spring

A library to simplify iOS animations in Swift.
http://designcode.io
MIT License
14.08k stars 1.8k forks source link

Shadow options for DesignableTextView, DesignableTextField, and DesignableImageView #316

Open ryanlietzenmayer opened 6 years ago

ryanlietzenmayer commented 6 years ago

These options were present for DesignableView and DesignableButton, but not DesignableTextView, DesignableTextField, and DesignableImageView. I do not know if this is an intentional choice, but this is an inconsistency.

I updated DesignableTextView, DesignableTextField, and DesignableImageView to match shadow options on existing views.

ryanlietzenmayer commented 6 years ago

The DesignableTextField and DesignableImageView changes are working, but I'm having trouble showing shadows with the DesignableTextView.

ryanlietzenmayer commented 6 years ago

With this change, DesignableTextView will only show shadows if clipsToBounds is set to false at or after viewDidLoad. It doesn't matter if it's unchecked and set to false for the view in Interface Builder.

I don't know where it's getting set to true.

ryanlietzenmayer commented 6 years ago
    @IBInspectable public var shadowOpacity: CGFloat = 0 {
        didSet {
            layer.shadowOpacity = Float(shadowOpacity)
            clipsToBounds = false
        }
    }

Adding clipsToBounds here makes shadows show in-app, but prevents the Clips to Bounds checkbox in Interface Builder from cutting off shadows like it does by default. Definitely not a graceful solution.

Note, setting clipsToBounds from a View Controller still works as it does by default.