A simple gradient view for iOS that wraps CAGradientLayer
in a better API.
CAGradientLayer
is a very powerful tool for displaying gradients in iOS
apps, but it can be difficult to configure correctly, especially for radial
gradients. GradientView
attempts to provide a more accessible API for it, while also wrapping it in a
UIView
, and handling dark and light mode changes, which CAGradientLayer
does
not do as it uses CGColor
which is unaware of interface style changes.
The code is documented with DocC, and the formatted documentation is available at https://dagagren.github.io/GradientView/documentation/gradientview.
You can use this repo as a Swift Package Manager package:
.package(url: "https://github.com/apple/swift-docc-plugin", exact: "1.0.0")
Or you can simply copy the GradientView.swift file into your project, it is the only file that is needed.
This code is released into the public domain with no warranties. If that is not suitable, it is also available under the CC0 license.