I am able to assign some images to a UIBarButton item--simple line icons easily in InterfaceBuilder. However, when I assign a full color image, it makes the entire image the color of the tint, blue for default value. If I set the tint to clear color the image disappears. I can't get it to show the image.
I know it is possible to show an image by creating an UIImageView, making a button and assigning the UIImageView to the button, but it seems strange that you have to go to all this trouble for some images, when other images display correctly by just assigning the image property in IB.
Does anyone know of a way to display a colored image without having to go through the whole rigamarole of creating a view etc.
something like btnItem.image = @"myimage.png";
Long way I would like to avoid...
UIImageView* v = [[UIImageView alloc] initWithFrame:CGRectMake(4, 0, 36, 36)];
UIImage *myImage = [UIImage imageNamed:@"headshot-32.png"];
v.image =myImage;
UIImage *scaledImage = [UIImage imageWithCGImage:[myImage CGImage] scale:(35) orientation:(myImage.imageOrientation)];
v.image=scaledImage;
v.layer.cornerRadius = v.frame.size.width / 2;
v.contentMode = UIViewContentModeScaleAspectFill;
v.clipsToBounds = YES;
UIBarButtonItem* roundBtn = [[UIBarButtonItem alloc] initWithCustomView:v];
self.navigationItem.leftBarButtonItems = @[roundBtn];