我正在尝试以编程方式创建一个tableview,在tableHeaderView中有一个搜索栏.由于某种原因,搜索栏出现在第一个单元格的顶部.
我正在使用Masonry来构建约束.
有人能指出我做错了什么.
- (void)setupViews {
...
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero];
[self.view addSubview:self.tableView];
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
self.tableView.tableHeaderView = self.searchBar;
...
}
- (void)updateViewConstraints {
[self.searchBar mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(self.view);
make.height.equalTo(@(44));
}];
[self.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
make.self.top.equalTo(self.view);
make.self.bottom.equalTo(self.toolbar.mas_top);
make.width.equalTo(self.view);
}];
...
}
Run Code Online (Sandbox Code Playgroud)

您可以在此处看到标题与单元格处于同一级别.

我正在尝试使用动画增加标签高度,但动画会使标签首先从中心展开,然后使用正确的y点跳转到位.这看起来很可怕.我想只有底部扩大.
[UIView animateWithDuration:0.5 delay:0.0f options:UIViewAnimationOptionTransitionNone animations:^{
[self.about increaseHeightFromTopLeft:deltaHeight];
[self.scrollView increaseContentHeight];
} completion:nil];
- (void)increaseHeightFromTopLeft:(CGFloat ) increased {
CGRect newFrame = CGRectMake(self.originX, self.originY, self.frameWidth, self.frameHeight + increased);
self.frame = newFrame;
}
Run Code Online (Sandbox Code Playgroud)
调用标签,您可以在此处看到动画视频.https://www.youtube.com/watch?v=DcqktIZ9moY&feature=youtu.be