Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set image from SDWebImage to background of button

I use SDWebImage in my project but I was wondering if there is a way to set the image to the background of a button?

like image 812
user5432778 Avatar asked Dec 15 '22 07:12

user5432778


1 Answers

You just need to import this class of SDWebImage

#import "SDWebImage/UIButton+webCache.h"

and UIButton+webCache this class is Category class so you can set your button background image like this,

[yourBTN sd_setBackgroundImageWithURL:[NSURL URLWithString:@"urlString.png"] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
like image 149
Mayank Patel Avatar answered Dec 27 '22 05:12

Mayank Patel