我在图像的右下方添加了一个阴影。
代码是
func addShadow(image: UIImage, blursize: CGFloat) -> UIImage {
let shadowColor = UIColor(white:0, alpha: 0.8).cgColor
let context = CGContext(data: nil, width: Int(image.size.width + blursize), height: Int(image.size.height + blursize), bitsPerComponent: image.cgImage!.bitPerComponent, bytesPerRow: 0, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)!
context.setShadow(offset: CGSize(width: 0, height: 0), blur: blursize, color: shadowColor)
context.draw(image.cgImage!, in: CGRect(x:0,y:blursize,width:image.size.width, height: image.size.height), byTiling: false)
return UIImage(cgImage: context.makeImiage()!)
}
我该怎么办?