我创建了一个带有标题和容器的视图...在容器内部有一个页面视图控制器
标题根据容器调整大小,通过iboutlet约束
如果容器中有一个表视图作为页面,那么标题会根据滚动偏移量调整大小,不带动画
如果我在页面之间滚动,我希望调整页眉大小,所以我创建了一个委托方法,用于监听滚动动画的结尾,然后调整标题大小
但如果我使用此代码为此大小调整设置动画
Intent notificationIntent = new Intent("android.media.action.DISPLAY_NOTIFICATION");
notificationIntent.addCategory("android.intent.category.DEFAULT");
notificationIntent.putExtra("eventName", eventName);
notificationIntent.putExtra("description", description);
PendingIntent broadcast = PendingIntent.getBroadcast(getApplicationContext(), notifNumber, notificationIntent, PendingIntent.FLAG_ONE_SHOT);
然后页面重新加载"调整大小后完成
这是一个动画视频(红色背景是我为编译调试而编辑的页面视图控制器的背景)
答案 0 :(得分:0)
请在动画块之外设置常量,
self.imageViewHeightConstraint.constant = ct
UIView.animate(withDuration: 0.5,animations: {
self.view.layoutIfNeeded()
}, completion: {_ in
UIView.commitAnimations()
if let handler = handler {
handler()
}
})