From df32a3e4e9cb02c459651c97f7636e7feea39bc2 Mon Sep 17 00:00:00 2001 From: sudeep Date: Sat, 1 Oct 2016 14:42:03 +0530 Subject: [PATCH] [FIX] Issue #2; shadow on iOS 10 --- ASJOverflowButton/ASJOverflowMenu.m | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ASJOverflowButton/ASJOverflowMenu.m b/ASJOverflowButton/ASJOverflowMenu.m index 09c7546..44b144a 100755 --- a/ASJOverflowButton/ASJOverflowMenu.m +++ b/ASJOverflowButton/ASJOverflowMenu.m @@ -98,11 +98,19 @@ - (void)layoutSubviews { [super layoutSubviews]; - // fixes shadow being drawn incorrectly - [self layoutIfNeeded]; - - [self setupShadow]; - [self animateMenu]; + /** + * Fix for Issue #2: https://github.com/sudeepjaiswal/ASJOverflowButton/issues/2 + * Thanks: http://stackoverflow.com/a/39647683 + * Weirdly, iOS 10 requires this stuff to be done on the main queue, else the menu position and shadow bounds don't set correctly, even though there is a call to focefully layout the view if needed. This was done earlier to fix shadow bounds in iOS 9 + */ + [[NSOperationQueue mainQueue] addOperationWithBlock:^ + { + // fixes shadow being drawn incorrectly. worked for iOS 9 + [self layoutIfNeeded]; + + [self setupShadow]; + [self animateMenu]; + }]; } - (void)setupShadow