Colour (color) flash during segue (Xcode) - ios

I'm fairly new to modern programming (the last serious experience I had was AMOS on my old Amiga!), but I've done my best to learn objective C with a view to developing an app (for iOS only at the moment). I've got a (hopefully very simple) question which I've done my best to research already without any joy.
I've got the bulk of my relatively basic app laid down already. From my home ViewController, I've got four options, all of which have colour-coded buttons, linked by segue to the content ViewControllers.
As a nice flourish, more than anything else, I'd like to make the whole screen flash briefly in the colour of the button pressed (this app is aimed at non-programmers, and a bit of theming will not only make things look good, but also hopefully aid orientation/ intuititivity.
So far I have tried:
adding a new ViewController with a screen blank except for the themed colour and an automated custom segue controlled by NSTimer. // This is sub-optimal as if the user wants to navigate back to the home page they have to jump through two pages rather than one, and if they're a bit slow then they may get stuck in a loop.
dicking around with NSTimer and self.window.backgroundColor/ setBackgroundColor. // both of these options end up with my app crashing - probably due to coding ineptitude!
Any ideas? For example, if my user clicked the 'Emergency Guidelines' UIButton, then I would have the screen flash red (the chosen theme colour for this section) for a barely perceptibly but subconsciously awesome period before seamlessly transitioning the app to the relevant page.
Sorry if it's a bit of a noobish question. I'm keen to hear any answers, even appropriately directed tough love.

I would suggest a different way. Don't use an extra viewController, instead add a colored UIView that covers the whole screen when the button was pressed. Animate a fade out, and once it's faded out completely remove that view and perform the push to the next viewController.
That's probably the easiest way, takes only this much code:
- (IBAction)demoButtonPressed:(UIButton *)sender {
UIView *flashView = [[UIView alloc] initWithFrame:self.view.bounds];
flashView.backgroundColor = [UIColor redColor];
[self.view addSubview:flashView];
[UIView animateWithDuration:0.3 delay:0.1 options:0 animations:^{
flashView.alpha = 0.0f;
} completion:^(BOOL finished) {
[flashView removeFromSuperview];
[self performSegueWithIdentifier:#"pushDemo1" sender:sender];
}];
}
Play around with duration and delay until you are satisfied.

have you looked into core animation? it would help if you therw up some code but i thing Apple's Core Animation tutorial is pretty straight forward with how you can trigger animation effects especially if a button is pressed like you mentioned for your color flash idea.
https://developer.apple.com/library/Mac/DOCUMENTATION/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html
you can also pull this up in X code which i suggest, or youtube some tutorials or github etc.
veritas

Related

make animations effects just like skype iOS application's menu

I was trying to create animation like skype bottom menu in iPhone. I tried many ways to solve it but wasn't able to configure the accurate solution.
I have tried,
(1)CGPathAddLineToPoint
(2)CGPathAddArc
(3)CGPathAddArcToPoint
(4)[UIView animateWithDuration:5000 delay:500 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:option animations:^{
square.layer.cornerRadius = 25;
square.layer.masksToBounds = YES;
} completion:^(BOOL flag){
square.layer.cornerRadius = 0;
square.layer.masksToBounds = YES;
}];
and some UIKit Dynamic approaches too. Unfortunately none of them worked for me to get exact solution. Main problem that i was facing was that CornerRadius rounds whole view, where i need something Curved/Arc. Ark approach also didn't provides needed solution.
Animation in Skype works this way.
Working Demo
(1)Firstly user taps on bottom right,
(2)Then menu animates upward with a curved (curved outside) effect,
(3) After collision with top boundary (i guess it is using UIKit Dynamic and on top there is an invisible boundary), Menu shows a bounce back effect and again shows a curved effect but this time curve inside,
Kindly guide if i'm using right approach or what should i do?
Thanks
this is a nicely written tutorial on how to create such animation: http://holko.pl/2014/06/26/recreating-skypes-action-sheet-animation/
At the end of the tutorial, the author also includes the github address that hosts a reusable framework that you can directly use to create such effect.
Hope this helps.

Animating slide show in iOS

Anybody have any idea how this is done?
http://youtu.be/r_cII4_aq_A
In general, the idea is awesome, but I would like to know how to do each specific thing. In the video, the pages are being swiped too fast so you can't see, but as you transition from one page to the next, each pixel smoothly transitions to it's new color. Also, it's really cool how the icon gets smaller to a minimum size as you transition away from a screen.
Maybe there's some 3rd party library that provides a protocol and it's relatively easy to implement, but I can't find it. If there's not, I'm thinking it's just one view controller with many views side by side and as you drag your finger, it calculates where each view needs to be..and what color every pixel needs to be.
I imagine you already have it by now. But in case you still have any doubts, I made gist that does the animation: https://gist.github.com/mnmaraes/9536364
Anyways, have fun.
It's a fade animation, so:
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
_backgroundImageView.image = nextImage;
} completion:nil];
should do the trick for the background part.
For the foreground/icon part you can animate the transform to scale and translate the views as they slide in and out.

how to animate UIImageview exactly pages of books

I have gone through various posts for animating UIImageview like
books pages but didn't find anything useful.
Actually I want to have animation on UIImageView to have the same effect as we have while
turning books's pages. I have used the following code to turn the UIImageview:
[UIView transitionWithView:self.greetingImgView
duration:1.0f
options:UIViewAnimationOptionTransitionCurlUp
But I am not able to get the desired page curl animation as we have while turning books pages.
I want a kind of animation where the user can have a feel of book page animation while viewing animation.
Please help me; I have researched a lot.
if you want a book like interface for your app, why not using the UIPageViewController. This class provides all you need and you can set the pageing animation as you want.

`pushViewController:animated:` with fade animation (animate transition only)?

There a lot of similar questions with answers. For example:
link
but almost all of them are unsuitable because I also want to perform something like this:
button1.frame = button2.frame;
button2.hidden = YES;
So if I use an example with beginAnimations: then I can see how button1 changes its frame (it moves while app perfoms a transition animation).
How to solve this issue? First of all should I set a button frame in another way or should I find another code for transition?
EDITED
Additionally I have found out that not all ways allow to show fade animation I need so I have edited my question a little.
link
The best solution from it is animating way which works for my case.
The most strange thing is to disable view controller's own animation instead of its changing.

iOS AwesomeMenu Delegation and Overlays

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 a completion: 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.

Resources