How to display a UIButton on top of it's UITableViewCell's text?

152 Views Asked by At

I am having trouble figuring out how to place a UIButton with a custom image above the text in the UITableViewCell that it belongs to. Is there a way to reorder the items outside of the visible storyboard hierarchy?

In the storyboard, I have tried:

  1. Setting the button to opaque.
  2. Unchecking 'Clip Subviews' in for the cell view.

Nothing I tried works. Below is a picture of how it appears now.

Notice how the text is in front of the button?

2

There are 2 best solutions below

1
On

If I understand your question correctly, you need the following code to insert your subview above the UILabel.

[self.view insertSubview:<#(UIView *)#> aboveSubview:<#(UIView *)#>];

Hope that helps!

0
On

I figured out what I needed to do:

UIButton * button = (* obtain button *)
[button.superview bringSubviewToFront:button];