日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

这是一个UIImage集合类,可以很方便的对图片的染料(着色),增加亮度(闪电)和降低亮度(黑)和其他扩展的功能模块。...

發布時間:2025/3/8 52 豆豆

2019獨角獸企業重金招聘Python工程師標準>>>

這是一個UIImage集合類,可以很方便的對圖片的染料(著色),增加亮度(閃電)和降低亮度(黑)和其他擴展的功能模塊。

在swift下實現圖片染色

import UIKitextension UIImage {/// Just change a colored color image, is to change the image TintColo////// - Parameter tintColor: Need to change the color of the color/// - Returns: Returns an imagefunc imageWithTintColor (tintColor: UIColor? = nil, alpha: CGFloat) -> UIImage? {let rect = CGRect(x: 0.0, y: 0.0, width: self.size.width, height: self.size.height)UIGraphicsBeginImageContextWithOptions(rect.size,false,self.scale)draw(in: rect)let ctx = UIGraphicsGetCurrentContext()ctx!.setFillColor((tintColor?.cgColor)!)ctx!.setAlpha(alpha);ctx?.setBlendMode(.sourceAtop)ctx!.fill(rect);let result = UIGraphicsGetImageFromCurrentImageContext()UIGraphicsEndImageContext()return result} }

Usage To swift

override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view, typically from a nib.let gift01ImageView = UIImageView(image: UIImage(named: "ic-gift"))gift01ImageView.frame = CGRect(x: 50.0, y: 50.0, width: 48.0, height: 48.0)self.view!.addSubview(gift01ImageView)let gift02ImageView = UIImageView(image: UIImage(named: "ic-gift")?.imageWithTintColor(tintColor: UIColor.blue, alpha: 0.5))gift02ImageView.frame = CGRect(x: 125.0, y: 50.0, width: 48.0, height: 48.0)self.view!.addSubview(gift02ImageView)}

gitHub Demo下載地址

轉載于:https://my.oschina.net/kinglyphp/blog/786718

總結

以上是生活随笔為你收集整理的这是一个UIImage集合类,可以很方便的对图片的染料(着色),增加亮度(闪电)和降低亮度(黑)和其他扩展的功能模块。...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。