Hide UIButton title

kris picture kris · Sep 4, 2011 · Viewed 15.3k times · Source

I have several UIButtons in a scrollview which I use in order to pass certain information. The information is saved in the title of each uibutton and when the button is clicked, it passes its title into the function.

All I want to do is hide the title of the button so you can not see the button. I have them overlaid over images which I use to show buttons. I have the text set to transparent but it still turns white when it is being clicked.

If you include code in your explanation, please explain where it should go.

Answer

Ohmy picture Ohmy · Oct 17, 2014

After IOS7, If you want to just hide the title on titleLabel of a button you can do as follow. This way the title is still there it just makes it invisible. if you do NSLog("%@",button.currentTitle) you will see the title in terminal. Hope this helps.

[button setTitle:@"Button Title" forState:UIControlStateNormal];
button.titleLabel.layer.opacity = 0.0f;