簡體   English   中英

如何在swift上更改pdf圖像顏色?

[英]How to change pdf image Color on swift?

我添加了一個按鈕並設置了pdf圖像。 我需要更改pdf圖像顏色。 可以做到嗎?

您可以使用此擴展方法來設置圖像顏色,

import UIKit

extension UIButton {

    public func setImage(color: UIColor, for state: UIControl.State) {
        let image = self.image(for: state)
        self.setImage(image?.withRenderingMode(.alwaysTemplate), for: state)
        self.tintColor = color
    }
}

用法

yourButton.setImage(color: .red, for: .normal)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM