TintingButton 是 UIButton 的子类,利用 tintColor 和 UIImage 渲染模式。
All Colored mode
[
let btnShare = TintingButton(completelyTintedWith: .whiteColor(), activeTintColor: .greenColor()) btnShare.setImage(imageShare, forState: UIControlState.Normal) btnShare.setTitle(title, forState: UIControlState.Normal)
Title Image Colored mode
let btnShare = TintingButton(titleAndImageTintedWith: whiteColor(), activeTintColor: .greenColor()) btnShare.setImage(imageShare, forState: UIControlState.Normal) btnShare.layer.borderColor = .grayColor().CGColor btnShare.layer.borderWidth = 1 btnShare.setTitle(title, forState: UIControlState.Normal)