I’m adding this menu to an app I’m working on: http://mobiledevelopertips.com/open-source/ios-open-source-animated-menu.html
I’m relatively green to Objective C (only been working on it for less than a month) and I’m not entirely sure how to do the following:
1) I want to add a gray overlay to the entire screen when I hit the button to open the menu. I’ve looked for solutions but a lot of people seem to recommend DSActivityView which doesn’t work for me… I don’t need that loading bubble. I guess I could download the source and remove the bubble, but that might require more effort than it’s worth.
I would think that I could just instantiate an imageView, drop it at 0,0 and expand it to the bounds of the screen, sourced with a transparent gray PNG file…like
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"transparent_gray.png"]];
imageView.frame= CGRectMake (0,0,screenWidth,screenHeight);
[viewController addSubview:imageView];
However, this approach probably won’t work ( I’m guessing it won’t cover the nav controllers like tab bar and status bar). Furthermore, I’m not really sure how I’d get to access the viewController from within AwesomeMenu. I assume I’d have to pass a reference of the viewController that is instantiating the AwesomeMenu into one of AwesomeMenu’s functions in order to be able to deploy an imageView into the viewController?
2) I want to write a delegate that will fire when the opening menu animations stop, so I can write text onto the overlay’d screen. Is there a super easy way to do this or am I going to have to just guestimate with some timer start/callback and make the callback write the text onto my screen? Oh – I’ve never written a delegate before but I assume it becomes slightly complicated when I want them to fire upon animation end.
Um, I think you have some preconceived notions about the way UIKit works. For 1), I suggest searching SO for “view covers screen” and get a better understanding of the issue, especially associated with view animation. Secondly, there are many ways to accomplish your 2) item. If you have the source to AwesomeMenu you can just modify whatever animations it performs. If the animation was done with
animateWithDuration:animations:you can just add acompletion:block. If you have a need to do your completion animation from several places, you might consider a delegate. You might be able to write a category for AwesomeMenu to add the functionality. In your case, I think a simple code modification is all you need. Hard to tell without more code/facts, though.