From d35c677fb404999891a7c8c64fe6314c18b2c917 Mon Sep 17 00:00:00 2001 From: AfirSraftGarrier Date: Tue, 19 Jul 2016 22:01:20 +0800 Subject: [PATCH] 1 Correct the menu width when the orientation change. 2 Fix iOS 7.0 problem ( 7.0's offset should be 0 but current is 20). --- DropdownMenu/DropdownMenuController.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/DropdownMenu/DropdownMenuController.m b/DropdownMenu/DropdownMenuController.m index 82d441d..87a02be 100755 --- a/DropdownMenu/DropdownMenuController.m +++ b/DropdownMenu/DropdownMenuController.m @@ -192,6 +192,10 @@ - (void)iOS6_hideMenuCompleted { -(CGFloat)offset { + return ([self isLandscape] && !SYSTEM_VERSION_LESS_THAN(@"8.0")) ? 20.0f : 0.0f; +} + +-(bool)isLandscape { UIInterfaceOrientation interfaceOrientation; // Check if we are running an iOS version that support `interfaceOrientation` @@ -202,9 +206,15 @@ -(CGFloat)offset { interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation; } - return UIInterfaceOrientationIsLandscape(interfaceOrientation) ? 20.0f : 0.0f; + return UIInterfaceOrientationIsLandscape(interfaceOrientation); } +-(CGFloat)correctWidth { + CGRect screenRect = [[UIScreen mainScreen] bounds]; + CGFloat max = MAX(screenRect.size.width, screenRect.size.height); + CGFloat min = MIN(screenRect.size.width, screenRect.size.height); + return [self isLandscape] ? max : min; +} - (void) drawOpenLayer { [openMenuShape removeFromSuperlayer]; @@ -281,6 +291,7 @@ -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOr CGRect menuFrame = self.menu.frame; menuFrame.origin.y = self.menubar.frame.size.height - self.offset; + menuFrame.size.width = [self correctWidth]; self.menu.frame = menuFrame; [self drawClosedLayer];