iPhone UIBarButtonItem alpha of button image -
i've added button lower toolbar this:
uiimage *locationimage = [uiimage imagenamed:@"193-location-arrow.png"]; uibarbuttonitem *locationbutton = [[uibarbuttonitem alloc] initwithimage:locationimage style:uibarbuttonitemstylebordered target:self action:@selector(updatecurrentlocation)]; nsarray *items = [[nsarray alloc] initwithobjects:locationbutton,nil]; [toolbar setitems:items]; [items release]; [locationbutton release];
this works great, alpha of image picked fine, button displays this:
so, took code , modified create button in navigation bar:
uiimage *favouriteimage = [uiimage imagenamed:@"28-star.png"]; uibarbuttonitem *favouritebutton = [[uibarbuttonitem alloc] initwithimage:favouriteimage style:uibarbuttonitemstylebordered target:self action:nil]; self.navigationitem.rightbarbuttonitem = favouritebutton; [favouritebutton release];
the alpha doesn't seem picked on 1 - looks greyed out:
is there need set when using custom images in navigation bar?
thanks , regards,
rich
you convert image white few lines of code:
cgrect imagerect = cgrectmake(0, 0, inimage.size.width, inimage.size.height) cgcolorspaceref colorspace = cgcolorspacecreatedevicergb(); cgcontextref context = cgbitmapcontextcreate(data1, imagerect.size.width, imagerect.size.height, 8, imagerect.size.width * 4, colorspace, kcgimagealphapremultipliedlast); cgcontextcliptomask(context, imagerect, inimage.cgimage); cgcontextsetrgbfillcolor(context1, 1, 1, 1, 1); cgcontextfillrect(context, imagerect); cgimageref finalimage = cgbitmapcontextcreateimage(context); uiimage *returnimage = [uiimage imagewithcgimage:finalimage]; cgcontextrelease(context); cgcolorspacerelease(colorspace); cgimagerelease(finalimage);
Comments
Post a Comment