- (void)updateViewConstraints { @weakify(self); // 設置頁頭滾動廣告 [_zsyHeaderView mas_remakeConstraints:^(MASConstraintMaker *make) { @strongify(self); make.top.mas_equalTo(self.view.mas_top); make.left.mas_equalTo(self.view.mas_left); make.right.mas_equalTo(self.view.mas_right); make.height.mas_equalTo(self.headerViewHeight); }]; //tableView [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) { @strongify(self); make.top.mas_equalTo(self.zsyHeaderView.mas_bottom); make.left.mas_equalTo(self.view.mas_left); make.right.mas_equalTo(self.view.mas_right); make.bottom.mas_equalTo(self.view.mas_bottom); }]; //次句代碼必須寫 [super updateViewConstraints]; }
// 作改變屬性的代碼 // 後面2句代碼,表示立刻更新約束 [self.view layoutIfNeeded]; [self.view setNeedsUpdateConstraints];