如何 transitionWithView 并使原始视图在层次结构上更高
How to transitionWithView and have original view higher on hierarchy
基本上我有一个 UIView,它是一个日历月视图,然后我有一个年视图,其中包含一年中所有月份的按钮。我的预期动画是当点击 monthBar 按钮时,当前 monthView 将缩小并转到 Year 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
。我想将该视图置于 yearCalendarView
之前,然后最终从视图中消失。
使用insertSubview
方法,应该可以。
基本上我有一个 UIView,它是一个日历月视图,然后我有一个年视图,其中包含一年中所有月份的按钮。我的预期动画是当点击 monthBar 按钮时,当前 monthView 将缩小并转到 Year 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
。我想将该视图置于 yearCalendarView
之前,然后最终从视图中消失。
使用insertSubview
方法,应该可以。