I have a Round Rect Button that is correctly swapping out images. I want to also change the text within them, but that text does not show up. Most questions on StackOverflow seem to deal with one but not the other, and the ones that seem most related end up being for a BarItem of some sort.
From within the IBAction for the button’s touch, I have the following.
[sender setImage:[UIImage imageNamed:@"swappingCorrectly.png"] forState:UIControlStateNormal];
[sender setTitle:(@"Aww, this doesn't show up!") forState:UIControlStateNormal];
As mentioned, the image is switched just fine — but that label isn’t showing up. I use the same text-swapping line in another button that isn’t swapping images and it works fine.
It just doesn’t show up after the first tap. Anyone know what I can do to make that text show up?
This works for me.
I did notice that the label is to the far right as opposed to dead center. Is it possible the label is rendering in the wrong spot? Commenting out the setTitle yields the same results with button title being offset by the image.
How to turn a UIImageView into a button. Note: this is very dirty and should be wrapped into a class. I left in but commented out the code to just do something on tap. Whats not shown is the UIImageView that was thrown on a xib file and set to userenabled = true.