UITableView goes under translucent Navigation Bar

前端 未结 14 1095
一整个雨季
一整个雨季 2020-12-22 23:51

I am trying to have a transparent navigation bar in IOS 7 app. There is a full screen image in my application. I am also having a UITableView over that image. When I use the

14条回答
  •  星月不相逢
    2020-12-23 00:26

    I came up with the following solution, which, on navigating to the view controller for the first time, adjusts the table view's contentInset for the navigation bar's height, taking into account any padding that the top cell might have. When returning to this view controller after pushing another view controller onto the stack, I then re-adjust the contentInset to UIEdgeInsetsZero:

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        [self adjustEdgeInsetsForTableView];
    }
    
    - (void)adjustEdgeInsetsForTableView {
        if(self.isMovingToParentViewController) {
            self.tableViewForm.contentInset = UIEdgeInsetsMake(self.navigationController.navigationBar.frame.size.height + padding, 0, 0, 0);
        } else {
            self.tableViewForm.contentInset = UIEdgeInsetsZero;
        }
    }
    

提交回复
热议问题