I have a tableview and I want to add as a subview a grey view with another view in order to imitate a pop-up. The problem is that the grey view doesn't cover the whole tv and the subview where I have my buttons isn't all visible if the bottom of tv is displayed.
Here is my code:
- (IBAction)orderButtonAction:(id)sender {
_grayView = [[UIView alloc]init];
_grayView.frame = [[UIScreen mainScreen]bounds];
_grayView.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.7];
_grayView.hidden = NO;
_profileOrderView.hidden = NO;
_tableView.scrollEnabled = NO;
_orderButtonOutlet.hidden = YES;
_profileOrderView.center = self.view.center;
[_grayView addSubview:_profileOrderView];
[_tableView addSubview:_grayView];
}
Is there a way to get the visible rect of tv and insert my grey view there?
If you want the greyView to cover the entire UITableView, you should set the frame of greyView as
[greyView setFrame:tableView.bounds].
If you want it to only cover the area of tableView shown, you should use the CGRectIntersection(self.frame, superview.bounds); and set it as the frame.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With