iOS CoreGraphics: UIImage's zoom and clip, linear Gradient, radial gradient, pdf to UIImage, UIImage to pdf...
iOS 绘图: 图片缩放、叠加、裁剪,线性渐变,径向渐变,PDF 转图片,图片转 PDF ...
- iOS 11.0+
- Xcode 12.2+
- Swift 5.0+
pod 'ImageCG'
If you prefer not to use either of the aforementioned dependency managers, you can integrate ImageCG into your project manually.
如果您不喜欢以上管理依赖库的方式,则可以手动将 ImageCG 集成到项目中。
let image = UIColor.red.icg.image(CGSize(width: 200, height: 100))
let color = myImage.icg.color
let newImage = myImage.icg.zoom(to: CGSize(width: 200, height: 100))
let newImage = myImage.icg.clip(in: CGRect(origin: .init(x: 10, y: 30), size: .init(width: 200, height: 300)))
let pdfPath: String = "read/to/path/my.pdf"
let images = UIImage.icg.readPDF(from: pdfPath, isJoin: false)
let myImage: UIImage = UIImage()
myImage.icg.savedPDF(to: NSHomeDirectory() + "saved/to/path/my.pdf")
let baseImage = UIImage(named: "BaseImageName")!
let logoImage = UIImage(named: "LogoImageName")!
let image = baseImage.icg.add(logoImage)
let colors = [UIColor.blue, UIColor.red, UIColor.yellow, ...]
let image = colors.icg.linearGradient(CGSize(width: 200, height: 100),
direction: .diagonally)
let colors = [UIColor.blue, UIColor.red, UIColor.yellow, ...]
let image = colors.icg.radialGradient(CGSize(width: 200, height: 100),
direction: .diagonally)
ImageCG is released under the MIT license. See LICENSE for details.
ImageCG 是在 MIT 许可下发布的,有关详情请查看该许可证。