ios - 如何转换WithView并使原始 View 在层次结构中更高

标签 ios objective-c uikit

基本上我有一个 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/

相关文章:

ios - 检测 UIStackView 间距中的点击(项目之间)

ios - textField 中的图标位置

ios - 默认 UISwitch 为 YES 然后使用 NSUserDefaults 保存状态

ios - 如何将 SQLite 文件中的更改迁移到现有应用程序中?

ios - 如何为所有iDevice设置背景图片?

objective-c - 如何在没有时间延迟的情况下从一种音乐序列更改为另一种音乐序列

objective-c - 将 NSData 字节数组转换为字符串?

iphone - 奇怪的 UIKit 错误, TableView 行保持选中状态

javascript - Ukit 模态阻止关闭退出按钮

ios - 线程 1 : signal SIGABRT error running on Xcode 11. 2.1