Reputation: 1147
I'm adding a gradient to a view and it's cutting off the width on one side.
My code for adding the gradient is
let gradientLayer = CAGradientLayer()
gradientLayer.frame = fadeView.frame
gradientLayer.colors = [UIColor.mainColor().cgColor, UIColor.white.cgColor]
fadeView.layer.addSublayer(gradientLayer)
The fadeView
is inside of a vertical stackView
, inside of a view
inside of a scrollView
, all of which have horizontal constraints on the left and right of 0, not constraining to margins.
The frame width for the fadeView
(and all other views other than the main view) is 320, but that might just be because of the device I'm testing on. The width of the screen is actually 375.
What's causing it to cut off like this?
Upvotes: 1
Views: 825
Reputation: 894
Change this
gradientLayer.frame = fadeView.frame
to
gradientLayer.frame = fadeView.bounds
Upvotes: 1