// 动态更改frame
- (void)show
{
CGFloat width = [[UIScreen mainScreen]bounds].size.width;
CGFloat height = [[UIScreen mainScreen]bounds].size.height;
[[UIApplication sharedApplication].keyWindow addSubview:self];
/**
* tbView 在这个view里高约束是200
目标把高改为500
*/
self.bgBtn.alpha = 0;
self.tbView.frame = CGRectMake(0, height, width, 500);
[self setNeedsLayout];
[self layoutIfNeeded];
[UIView animateWithDuration:.3f animations:^{
self.bgBtn.alpha = 0.3f;
self.tbView.frame = CGRectMake(0, height - 500, width, 500);
} completion:^(BOOL finished) {
}];
}
- (void)dismiss
{
CGFloat width = [[UIScreen mainScreen]bounds].size.width;
CGFloat height = [[UIScreen mainScreen]bounds].size.height;
[UIView animateWithDuration:0.3 animations:^{
self.bgBtn.alpha = 0;
self.tbView.frame = CGRectMake(0, height, width, 400);
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
// Masonry 更改frame
[self setNeedsUpdateConstraints];
[UIView animateWithDuration:0.3 animations:^{
//NSInteger height = kCellHeight * 2 + 60 + 60;
[self mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.supView).with.offset(5);
make.right.equalTo(self.supView).with.offset(-5);
make.bottom.equalTo(self.supView).with.offset(-5);
make.height.mas_offset(240);
}];
[self.superview layoutIfNeeded];
}];
网友评论