UIView transparent gradient

This was an embarrassingly easy fix: apply a CAGradientLayer as my subview’s mask. CAGradientLayer *gradientLayer = [CAGradientLayer layer]; gradientLayer.frame = _fileTypeScrollView.bounds; gradientLayer.colors = [NSArray arrayWithObjects:(id)[UIColor whiteColor].CGColor, (id)[UIColor clearColor].CGColor, nil]; gradientLayer.startPoint = CGPointMake(0.8f, 1.0f); gradientLayer.endPoint = CGPointMake(1.0f, 1.0f); _fileTypeScrollView.layer.mask = gradientLayer; Thanks to Cocoanetics for pointing me in the right direction!

CAGradientLayer, not resizing nicely, tearing on rotation

When you create a layer (like your gradient layer), there’s no view managing the layer (even when you add it as a sublayer of some view’s layer). A standalone layer like this doesn’t participate in the UIView animation system. So when you update the frame of the gradient layer, the layer animates the change with … Read more

How to Apply Gradient to background view of iOS Swift App

Xcode 11 • Swift 5.1 You can design your own Gradient View as follow: @IBDesignable public class Gradient: UIView { @IBInspectable var startColor: UIColor = .black { didSet { updateColors() }} @IBInspectable var endColor: UIColor = .white { didSet { updateColors() }} @IBInspectable var startLocation: Double = 0.05 { didSet { updateLocations() }} @IBInspectable var … Read more