部分场景,基本动画不执行:
[UIView animateWithDuration:animationDuration animations:^{ } completion:^(BOOL finished) { }];
其实想解决很简单,就是调用布局重新绘制函数:[self layoutIfNeeded];
具体的例子是:
[_comTool setKeyBoardChangeBlock:^(CGFloat height, CGFloat animationDuration) {
if (DYGlobleData.isLogin) {
if(animationDuration <= 0)
{
//防范式编程,理论不会出现
weakSelf.bgV.hidden = NO;
}
else
{
weakSelf.bgV.hidden = (height<=0);
[UIView animateWithDuration:animationDuration animations:^{
if((height<=0))
{
[weakSelf.comTool mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(BaseSize(100));
make.width.mas_equalTo(KScreenW);
make.bottom.mas_equalTo(BaseSize(100) -(49+(BR_BOTTOM_MARGIN?24:0)));
}];
[weakSelf.comTool updateCommentTVWithShift:(BaseSize(100) -(49+(BR_BOTTOM_MARGIN?24:0))+(BR_BOTTOM_MARGIN?24:0))];
}
else
{
[weakSelf.comTool mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(BaseSize(100));
make.width.mas_equalTo(KScreenW);
make.bottom.mas_equalTo(-height);
}];
[weakSelf.comTool updateCommentTVWithShift:0];
}
[weakSelf layoutIfNeeded];
} completion:^(BOOL finished) {
}];
}
} else {
weakSelf.bgV.hidden = YES;
[weakSelf.comTool mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(BaseSize(100));
make.width.mas_equalTo(KScreenW);
make.bottom.mas_equalTo(BaseSize(100) -(49+(BR_BOTTOM_MARGIN?24:0)));
}];
[weakSelf.comTool updateCommentTVWithShift:(BaseSize(100) -(49+(BR_BOTTOM_MARGIN?24:0))+(BR_BOTTOM_MARGIN?24:0))];
};
}];