我有一个UIView(称之为通知视图),里面有一个scrollView(使用addSubView)。我希望将此视图显示为带有动画的弹出窗口。所以在开始时我把它的高度设为0,并且在动画块中我将它的高度设置为欲望数字。当我想隐藏这个视图时,我在动画块中将其高度设置为0。它的工作正常。问题是
我想为通知视图创建缩小/展开效果。要显示弹出窗口,我正在使用以下动画块
[UIView animateWithDuration:1.0
animations:^{
notificationParentView.frame = CGRectMake(50, 52, 220, 200);
downArrowIcon.transform = CGAffineTransformMakeRotation(M_PI);
}];
要隐藏此弹出窗口,请执行以下代码
[UIView animateWithDuration:1.0
animations:^{
notificationParentView.frame = CGRectMake(50, 52, 220, 0);
downArrowIcon.transform = CGAffineTransformMakeRotation(0);
}completion:^(BOOL finished){
[notificationParentView removeFromSuperview];
}];
notificationParentView可以很好地扩展和缩小,但它的子视图不会使用父视图.i.e.notificationParentView进行扩展/缩小。有什么明显的我遗失了吗?
答案 0 :(得分:0)
您可以使用CGAffineTransform
//Appear animation
notificationParentView.transform = CGAffineTransformConcat(CGAffineTransformMakeScale(0, 1), CGAffineTransformMakeRotation(M_PI)) // Set to hidden state
[UIView animateWithDuration:1.0
animations:^{
notificationParentView.transform = GAffineTransformIdentity;// Set back to normal, displaying state
}];
//disappear
[UIView animateWithDuration:1.0
animations:^{
notificationParentView.transform = CGAffineTransformConcat(CGAffineTransformMakeScale(0, 1), CGAffineTransformMakeRotation(M_PI)); //Back to hidden state.
}];