개발
swift] UIbutton의 UIimage 색상변경하기
dev.jake
2021. 8. 4. 10:33
https://stackoverflow.com/questions/27163171/change-color-of-png-in-buttons-ios
btn.setImage(name: "testImage", for: .normal)
btn.setImageTintColor(UIColor.red)
extension UIButton{
func setImageTintColor(_ color: UIColor) {
let tintedImage = self.imageView?.image?.withRenderingMode(.alwaysTemplate)
self.setImage(tintedImage, for: .normal)
self.tintColor = color
}
}