How to create a radial gradient in a square shape?
(source: graphicxtras.com)
How to create a radial gradient in a square shape?
(source: graphicxtras.com)
You can draw a radial gradient directly in a UIView subclass like this:
override func draw(_ rect: CGRect) {
let context = UIGraphicsGetCurrentContext()!
let colorSpace = CGColorSpaceCreateDeviceRGB()
let colors = [UIColor.red.cgColor, UIColor.green.cgColor] as NSArray
let gradient = CGGradient(colorsSpace: colorSpace, colors: colors, locations: nil)!
let center = CGPoint(x: bounds.midX, y: bounds.midY)
context.drawRadialGradient(gradient, startCenter: center, startRadius: 0, endCenter: center, endRadius: bounds.width/2, options: [.drawsAfterEndLocation])
}
Or simply check out this lib to draw any gradient you want out of the box - https://github.com/maxkonovalov/MKGradientView
I can suggest you 2 ways.
First:
You can make 2 UIViews one inside the other with constraints to the inside UIView so that it is in the center and smaller than the other. Then you add background color to the inside UIView yellow and for the other UIView you can use this library https://github.com/ViccAlexander/Chameleon and make a UIGradientStyleRadial color with yellow and back.
Second: You can use https://www.paintcodeapp.com/ which will be also lighter for your app