From 15f750aff4add21536d4c8d62ff77a51b3e69f7b Mon Sep 17 00:00:00 2001 From: James Hurst Date: Fri, 5 Feb 2016 15:39:50 -0500 Subject: [PATCH] Fixed contentOffset when calendar is shorter than the view --- FSCalendar/FSCalendar.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FSCalendar/FSCalendar.m b/FSCalendar/FSCalendar.m index 7a13032..5056976 100644 --- a/FSCalendar/FSCalendar.m +++ b/FSCalendar/FSCalendar.m @@ -1206,7 +1206,7 @@ typedef NS_ENUM(NSUInteger, FSCalendarOrientation) { // Force layout to avoid crash on orientation changing [_collectionViewLayout layoutAttributesForElementsInRect:_collectionView.bounds]; CGRect headerFrame = [_collectionViewLayout layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader atIndexPath:[NSIndexPath indexPathForItem:0 inSection:scrollOffset]].frame; - CGPoint targetOffset = CGPointMake(0, MIN(headerFrame.origin.y,_collectionView.contentSize.height-_collectionView.fs_bottom)); + CGPoint targetOffset = CGPointMake(0, MIN(headerFrame.origin.y,MAX(0,_collectionView.contentSize.height-_collectionView.fs_bottom))); [_collectionView setContentOffset:targetOffset animated:animated]; } else {