-
Notifications
You must be signed in to change notification settings - Fork 43
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
Gradient not updating on orientation change. #5
Comments
yes same problem here |
Same here. Updating height constraints of the gradient view gives me white space on the extended parts. |
I used this library |
Thanks. Will try it. Tried the autoresizingMask on this one and it does not work. update |
Try this, it worked for me
|
To get a smooth orientation change animation the CAGradientLayer should be used as the UIView backing layer. This is my solution with Swift 4: import EZYGradientView
@IBDesignable
open class _EZYGradientView: EZYGradientView
{
public required init?(coder aDecoder: NSCoder)
{
super.init(coder: aDecoder)
self.gradientLayer = self.layer as? CAGradientLayer
}
override open func draw(_ rect: CGRect) {
if self.gradientLayer == nil {
self.gradientLayer = self.layer as? CAGradientLayer
}
super.draw(rect)
}
override open class var layerClass: Swift.AnyClass {
get {
return CAGradientLayer.self
}
}
} Problem is well explained here: https://stackoverflow.com/questions/17555986/cagradientlayer-not-resizing-nicely-tearing-on-rotation-video-of-issue-attac |
- Replace Backing layer class with CAGradientLayer class - Remove layer creation and insertion - Fix shashankpali#5
I have set EZYGradientView in interface builder, in portrait mode, but when I change the orientation to landscape the gradient does not update.
The text was updated successfully, but these errors were encountered: