Skip to content

Instantly share code, notes, and snippets.

@roalcantara
Created April 11, 2012 10:34
Show Gist options
  • Save roalcantara/2358538 to your computer and use it in GitHub Desktop.
Save roalcantara/2358538 to your computer and use it in GitHub Desktop.
iOS > UIButton Background from url
NSURL* url = [NSURL URLWithString:photoURL];
NSURLRequest* request = [[NSURLRequest alloc] initWithURL: url];
NSHTTPURLResponse *response = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
UIImage* photo = [[UIImage alloc] initWithData:responseData];
[self.btn setImage:photo forState:UIControlStateNormal];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment