基本上我有一个 UIView,它是一个日历月 View ,然后我有一个年 View ,其中包含一年中所有月份的按钮。我的预期动画是当点击 monthBar 按钮时,当前 monthView 将缩小并转到 Year View 上当前月份的预期帧。我有这个正确的动画,但是前面的原始 View currentMonthView 位于 YearView 后面而不是在顶部。这是我现在拥有的:
- (IBAction)monthBarTapped:(id)sender
{
if (_monthBarImageView.highlighted) {
[self _animateOutYearCalendar:0];
return;
}
_calendarYear = [_calendarStartDate year];
[self _refreshYearCalendar];
// animate in year calendar
_yearCalendarView.hidden = NO;
[_yearCalendarView setFrameHeight:0];
self.curMonthView.monthLabel.hidden = YES;
_curMonthView.transform = CGAffineTransformIdentity;
[UIView animateWithDuration:5.5 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
[self bringSubviewToFront: _curMonthView];
_curMonthView.frame = _curMonthButtonFrame;
_curMonthView.transform = CGAffineTransformMakeScale(0.01, 0.01);
} completion:^(BOOL finished) {
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(yearCalendarAnimationDidStop:finished:context:)];
}];
// [UIView beginAnimations:@"animateYearCalendarIn" context:nil];
// [UIView setAnimationDuration:0.5]; // kAnimation_AnimateInDuration];
// [UIView setAnimationDelegate:self];
// [UIView setAnimationDidStopSelector:@selector (yearCalendarAnimationDidStop:finished:context:)];
//
[_yearCalendarView setFrameHeight:_yearFlyoutHeight];
//
// [UIView commitAnimations]; // start animation
_monthBarImageView.highlighted = YES;
[self _refreshMonthButton:NO];
}
TLDR:框架收缩到正确的位置,但 _curMonthView
在动画期间在显示层次结构方面落后于 yearCalendarView
。我想将该 View 置于 yearCalendarView
的前面,然后最终从 View 中消失。
最佳答案
使用 insertSubview
方法,应该可以。
关于ios - 如何转换WithView并使原始 View 在层次结构中更高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32570692/