gpt4 book ai didi

ios - 如何从主视图中的特定位置淡入 UIVIew

转载 作者:行者123 更新时间:2023-11-29 10:25:53 25 4
gpt4 key购买 nike

我的应用目前有两种模式,一种是月 View ,它显示月份中的每个日期 (1->31),而当您单击一个按钮时,日历会转变为显示每个月的年 View 。我想要做的是在年模式下,当我单击返回月模式时,我想加载当前月份的月 View ,同时从该月淡入。

这是月 View : enter image description here

当您单击顶部标题栏(2015 年 9 月)时,年度 View 会从顶部动画显示

这是年 View :

enter image description here

TLDR:当您在月 View 中单击顶部标题栏时,我想加载年历 View 并从以蓝色突出显示的日期位置(在本例中为 9 月 2 日)扩大该 View 。这是我目前拥有的

- (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;

[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];
}

- (void)_animateOutYearCalendar:(long)month
{
[UIView beginAnimations:@"animateYearCalendarOut" context:nil];
[UIView setAnimationDuration:0.5]; // kAnimation_AnimateInDuration];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector (yearCalendarAnimationDidStop:finished:context:)];

[_yearCalendarView setFrameHeight:0];
[UIView commitAnimations]; // start animation

if (month > 0) {
// set the new month/year
if ((month != _calendarStartDate.month) || (_calendarYear != _calendarStartDate.year)) {
// they changed the date
NSDateComponents *comps = [_calendar components:NSCalendarUnitMonth | NSCalendarUnitYear fromDate:_calendarStartDate];
comps.month = month;
comps.year = _calendarYear;
_calendarStartDate = [_calendar dateFromComponents:comps];
[self _refreshDisplay];
}
}
}

基本上,我想知道如何从特定位置加载和扩大 View ,以及如何将 View 缩小和折叠到特定位置。

谢谢!

最佳答案

如果我明白你在问什么,你想要这样的东西

_monthView.alpha = 0;
_monthView.frame = button.frame;
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
// Do all the animations you want in this block
_monthView.frame = CGRectMake(_destination.frame.origin.x,
_destination.frame.origin.y,
_destination.frame.size.width,
_destination.frame.size.height);
// where destination is where you want to animate to
_monthView.alpha = 1.0;

}
completion:^{
//call what ever method you want when animation finishes
}];

关于ios - 如何从主视图中的特定位置淡入 UIVIew,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32359463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com