I have .png images, and my backgrounds are white. I wanted a quick solution to transform the white background in a transparent background (code solution) as the app bg is grey and not white. I already tried CSS (pixate) but it doesn't work.
-(void)getImageFromeRequestedUrl:(NSString*)urlRequested {
NSString *userName = @"userName";
NSString *password = @"passWord";
NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlRequested]];
NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", userName, password];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)];
[urlRequest setValue:authValue forHTTPHeaderField:@"Authorization"];
AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Response: %@", responseObject);
self.image.image = responseObject;
self.image.frame = CGRectMake(0, 0, 300, 300);
self.image.center = self.image.superview.center;
self.image.backgroundColor = [UIColor clearColor];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Image error: %@", error);
}];
[requestOperation start];
}