jake9115
jake9115

Reputation: 4084

How to make a UIButton invisible but also still work if pressed?

I have a situation in which I need to have a button added to my view using Interface Builder, but the button shouldn't be seen, but if the user clicks the location of the button, the button can still call its method.

I've tried setting the opacity to zero, or changing the button to 'hidden', but both of these strategies result in a button that is completely invisible, but also useless, as it can't be pressed.

Does anyone have a solution for this?

Upvotes: 0

Views: 881

Answers (1)

Valent Richie
Valent Richie

Reputation: 5226

You can try to custom type UIButton:

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

With empty title, empty background image.

Or set the type from the storyboard or Interface Builder:

Custom type UIButton

Upvotes: 7

Related Questions