我有UIView画画。
我可以更改默认的笔划线
CGContextSetStrokeColorWithColor(context,UIColor.blackColor()。CGColor)
到https://www.img.in.th/image/79xF 或http://catheria.com/wp-content/uploads/2015/10/StrokeLinear.png
下面是代码绘制半径渐变
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
let ctx0 = UIGraphicsGetCurrentContext()
let colorSpace: CGColorSpaceRef = CGColorSpaceCreateDeviceRGB()!
let locations: [CGFloat] = [0.0, 0.4, 1.0]
let arrColor = [UIColor.blackColor().CGColor,UIColor.blackColor().CGColor, UIColor.clearColor().CGColor]
let _gradient: CGGradientRef = CGGradientCreateWithColors(colorSpace, arrColor, locations)!
CGContextDrawRadialGradient(ctx0, _gradient, CGPoint(x: size.width/2, y: size.height/2), CGFloat(0), CGPoint(x: size.width/2, y: size.height/2), CGFloat(60), CGGradientDrawingOptions())
let _img0 = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()