ios - Avoid white background in UIImageView -
ios - Avoid white background in UIImageView -
i have .png images, , backgrounds white. wanted quick solution transform white background in transparent background (code solution) app bg gray , not white. tried css (pixate) 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]; }
if mean actual physical image background white here possible solution using uiimageview. bear in mind work if background white (as in rgb #ffffff). also, if other element in image white, colored (or in case, disappear). oh, , need @ to the lowest degree ios7.
uiimage *yourimage = ... uiimageview *yourimageview = ... ... yourimageview.image = [yourimage imagewithrenderingmode:uiimagerenderingmodealwaystemplate]; yourimageview.tintcolor = [uicolor clearcolor]; but much improve if modified actual image in graphics programme yourself.
ios objective-c uiimageview png
Comments
Post a Comment