diman4eg
diman4eg

Reputation: 57

How to present an invisible interacting button above the UIImageView

In my app I want to pick some image from the gallery or the camera via ImagePicker (this part works fine though) and present it in UIImageView. So in IB I created a view, button, and a method (which selected an image):

@property (retain, nonatomic) IBOutlet UiImageView *sourceImageView;
@property (retain, nonatomic) IBOutlet UiButton *selectImageButton;

-(IBAction)selectImage;

On the first run of the app I need to present a button instead of a View, so I put it above the view in IB and make the view hidden. But after the user picks up the image, it needs to be presented in the view instead of the button, and if user wants to select another image, he sould pressed on the displayed image and pick another. So, I think, I need to set the button invisible somehow, but it should be above the view and react to touches. I'm trying an obvious decision:

-(void)viewDidAppear{
_selectedImageButton.hidden=YES;
_sourceImageView.hidden=NO;

and it's untouchable. I tried also to set the _selectImageButton.alpha to minimum values, it works, until it's equal to 0. But in that case a bit of a button is still visible above the view, and I can't accept it. I feel that there should be some easy way to do this, because the problem seems to be common.

Upvotes: 2

Views: 619

Answers (1)

Daij-Djan
Daij-Djan

Reputation: 50089

from H2CO3's comment:
If you create a button of style UIButtonTypeCustom, then it will be invisible by default (due the lack of sensible default graphics properties)

just have the button be transparent that way and there is no need to hide anything

Upvotes: 1

Related Questions