我的應用程序目前有兩種模式,一個月視圖,它顯示月份中的每個日期(1-> 31),當您單擊按鈕時,日曆轉換爲每年顯示每月的年份視圖。我想要做的是在年模式下,當我點擊返回到月模式時,我想從當月開始加載月份視圖,並從當月開始淡入。如何從主視圖中的特定位置淡入UIVIew
當您單擊頂部標題欄(2015年9月),每年從山頂
這裏動畫中的年視圖:
TLDR:當您在月視圖中單擊頂部標題欄時,我想加載年份日曆視圖並從日期位置增加該視圖(在這種情況下9月2日)以藍色突出顯示。 這裏是我目前
- (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];
}
}
}
基本上,我想知道如何加載和從一個特定的位置增加一個視圖,以及如何收縮和崩掉着眼於一個特定的位置。
謝謝!
您可能想要將視圖的框架從按鈕框架動畫到屏幕的整個框架(可能不包括導航欄)。 – Aaron
是的,這正是我想要做的 –