在自定义单元格中对view使用了masnory约束后会发现
获取的view的frame都是0
__weak typeof (self) weakSelf = self;
[self addSubview:self.backGreenView];
[self.backGreenView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.bottom.mas_equalTo(weakSelf);
}];
解决办法就是在layoutSubviews里去拿view.frame
- (void)layoutSubviews{
[super layoutSubviews];
NSLog(@"frame:%@",NSStringFromCGRect(self.frame));
}
网友评论