1

I am trying to place a UIButton inbetween my popup view and the parent view.

I cant successfully do that by doing that [self.view addSubview:new];. My problem there is the border UIView can be seen across the UIButton .

I've tried [self.view.superview addSubview:new]; thinking that that would make it go away but it doesnt it still shows there.

I need to find a way to successfully place that button on top of everything (UIView border in this case).

I know I could do that if I insert the button from the parentView, but I want to handle all my subViews buttons within each subView, otherwise it everything will become messy very quickly.

Is there a way to do what I am trying to achieve?

enter image description here

Undo
  • 25,519
  • 37
  • 106
  • 129
Jonathan Thurft
  • 4,087
  • 7
  • 47
  • 78

1 Answers1

3

According to Apple's CALayer documentation, borders always appear above subviews because they're drawn on another layer. The best solution is to create a background view to fake the border.

So instead, your popup view would have an orange background. It'd have another, slightly smaller subview directly over it with a white background, and then your button.

diagram

See this post for the implementation.

Community
  • 1
  • 1
Austin
  • 195
  • 2
  • 9