Search code examples
iosobjective-cuitabbar

How can I place my target view on top of the tab bar?


I want to place my targetView right on top of the tab bar. I created a XIB-File with a targetLabel and a cancelButton.

I tried to place my targetView programmatically on top of my tab bar but I can´t figure out how to do it without space between them.

[self addOverlayView:self.targetView x:0 y:self.view.frame.size.height - self.targetView.frame.size.height - 10];

addOverview is a func I made to place a view where ever you want:

- (void)addOverlayView:(UIView*)v x:(CGFloat)x y:(CGFloat)y
{
    v.hidden = YES;
    CGRect vFrame = v.frame;
    vFrame.origin.x = x;
    vFrame.origin.y = y;
    
    if ((v.autoresizingMask & UIViewAutoresizingFlexibleWidth) != 0) {
        vFrame.size.width = topView.bounds.size.width;
    }
    v.frame = vFrame;
    [v.layer setTransform:CATransform3DMakeTranslation(0, 0, OVERLAY_TRANSLATION_Z)];
    
    [overlayView addSubview:v];
    
}

I don´t know if this was the right approach but it works for me (so far).

What do I have to change in so that my targetView is right on top of my tabBar?


Solution

  • Remove that -10 and check

      [self addOverlayView:self.targetView x:0 y:self.view.frame.size.height - self.targetView.frame.size.height];