我想实现的效果是这样的:
首页上显示一个轮播器,轮播器用Masonry
实现,轮播器下面是一个tableview,并且用Masonry
进行自动布局。
UI用代码实现。
NSArray* imageNames = @[@"checked", @"test1"];
_vCycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, 180) imageNamesGroup:imageNames];
[self.view addSubview:_vCycleScrollView];
[_vCycleScrollView mas_makeConstraints:^(MASConstraintMaker* make){
make.top.equalTo(self.view);
make.left.equalTo(self.view);
make.right.equalTo(self.view);
make.width.equalTo(self.view.mas_width);
}];
_vCategoryTableView = [[UITableView alloc] init];
_vCategoryTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_vCategoryTableView.delegate = self;
_vCategoryTableView.dataSource = self;
[self.view addSubview:_vCategoryTableView];
[_vCategoryTableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view);
make.top.equalTo(_vCycleScrollView).with.offset(10);
make.width.mas_equalTo(self.view.mas_width);
make.height.equalTo(self.view);
}];
轮播器完全显示不出来。
如果单把scrollview的constraint注释掉,可以显示出图片的底边
如何解决?
Such a carousel image is fixed at the top. If you want the carousel image to slide with the tableview, then you can use the carousel image as the header of the tableview and set the frame of the carousel image.
When I use masonry, make.right.equalTo(self.view) will constrain right to the left of the view.
If it is make.top.left.bottom.right.equalTo(self.view), it is the correct position. I guess it corresponds to UIEdgeinsets