Kingfisher: UIButton setImage not working. Blank

Created on 25 Feb 2018  Â·  2Comments  Â·  Source: onevcat/Kingfisher

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

Issue Description

What

When I try to use
button.kf.setImage(with: url, for: .normal, placeholder: nil, options: nil, progressBlock: nil, completionHandler: nil) on my UIButton it only shows blue colour image instead of loading actual image

Reproduce

I am attaching sample code please run and check.

simulator screen shot - iphone 8 plus - 2018-02-25 at 16 17 33

Other Comment

XCode 9.2
Swift 4.0
Kingfisher 4.6.2

[Add anything else here]

KFOnUIButton.zip

Most helpful comment

Button images are rendered as template by default. You may want to use the original version. Try something like this:

let modifier = AnyImageModifier { return $0.withRenderingMode(.alwaysOriginal) }
button.kf.setImage(with: url, for: .normal, placeholder: nil, options: [.imageModifier(modifier)], progressBlock: nil, completionHandler: nil)

All 2 comments

Button images are rendered as template by default. You may want to use the original version. Try something like this:

let modifier = AnyImageModifier { return $0.withRenderingMode(.alwaysOriginal) }
button.kf.setImage(with: url, for: .normal, placeholder: nil, options: [.imageModifier(modifier)], progressBlock: nil, completionHandler: nil)

I set the button's type to custom and it worked. (instead of system)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacowu picture jacowu  Â·  4Comments

vCrespoP picture vCrespoP  Â·  3Comments

Minitour picture Minitour  Â·  4Comments

litt1e-p picture litt1e-p  Â·  4Comments

wudijimao picture wudijimao  Â·  3Comments