Fade in Fade out button menu - iphone

I want to make a 'menu' with 4 options. This has to be 1 big frame where the buttons are being faded in and faded out over time, 1 by 1.
So only 1 button is visible at any given time , not 4;
These buttons ofcourse are filled with Images
I don't know how to start , i've checked out some photoalbum code but it hasn't helped me.
The main problem is the user can click at any time in the animation of fade in and fade out, so how to decide when to go where ?
Because when one imagebutton is faded out 50% another is 50% faded in.

try something like this....
[UIView beginAnimations:nil context:self.view];
[UIView setAnimationDuration:1];
[yourButton setImage:[UIImage imageNamed:your-image-name] forState:UIControlStateNormal];
[UIView commitAnimations];

if you dont want that the user can click during an animation then just disable (UIControl is inherited by UIButton) the buttons during animation.
You can set the UIView-Animation-Delegate to your class so your class gets notified when animation starts, ends, ...
[UIView setAnimationDelegate]
edit: if you want that the user can click on buttons during animation you have to know the wanted behaviour: which buttons should be clickable at which time?

Related

in ios dev, how to handle case based animations?

My questions is probably best asked by stating my problem:
In my app, there are two button choices, lets say 1 & 2. when you click and hold on 1, 2 fades out (alpha change) over .3 seconds, and vice versa.
If the user 'cancel's' that button touch (by dragging his finger away from the button and releasing) the opposite button fades back in.
This all works great. The problem arises when the user does not hold down on the button, and clicks it so a touch is registered in under .3 seconds (the time it takes for the other button to fade out) The thing is there are more animations that have to happen after all this so i guess my issue is that animations further down the line interrupt that .3 sec fade and things start to look awkward.
Suggestions to work with this? Thank you!
As suggested in this post, you should create a secondary UIView animation that goes to the same animation endpoint as your 0.3 second one. Make sure you set the animation to begin from the current state, and give it as short as time as it will let you. Basically this will get your views to all look like they would at the end of that first animation, and it will happen much more quickly. After that animation is done, you would do your other animations based on the button results.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.03];
[UIView setAnimationCurve: UIViewAnimationCurveLinear];
// here you set your view and animation stuff from the other animation that takes 0.3 seconds
[UIView commitAnimations];
This will get you quickly to the state you would be in after the 0.3 second animation and you can begin the animation from there.

sliding bar in iOS, like facebook when losing network connection

I need to provide a sliding bar in iOS to alert the user that he entered wrong data.
I want it to appear for about 1 second at the top of the screen and then disappear, so something with animcation and commit. but I couldn't find any good documentation for this.
Any ideas?
Thanks.
First you need an imageView of your notification bar or a button to be animating, which is yourObject.
With this method you put the banner on screen (change coordinates to whatever suites you) Also if you want it flip down as Apple has some of their notifications you can use the rotation, if not just delete that line.
//yourObject setHidden to NO
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.5];
self.yourObject.center = CGPointMake(100, 200);
self.yourObject.transform = CGAffineTransformMakeRotation(0);
[UIView commitAnimations];
Next just make a timer which after 1 second invokes some method to do the opposite of the one I have posted.
if you want a very simple appear and disappear instead of sliding you can replace the two lines before commitAnimations with
yourObject.alpha=1

Effect like deletion in ios

I need hint/code like deletion/move app effect on iOS, normally i have started the code, I am using UIButton list in UIScroll.
So my question is that supposes I have 8 to 10 button in screen and i want to change their position with dragging. for example choose 6th button and move or set to between 1 and 2. when I put them in to between the position of other button will change.
I am using UIPanGestureRecognizer for dragging.
download, Tiles-v1.0.zip, and check code, this is what i used when i needed to implement that.
reference: Move UIViews to avoid collision like rearranging icons on Springboard
If you already have the code for dragging, the rest is easy. Just use UIView Animation.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
...
[button setFrame:newFrame];
...
[UIView commitAnimations];
Basically, just move your buttons to the their new positions in that beginAnimations - commitAnimations block.
Hope this helps.

Label and button don't go in background

In my iPhone project, I have a mapview. I have one custom button and a label on map view. When user clicks on a pin a callOutAnnotation is called. I have a different class for CallOutAnnotation. A view for callOutAnnotation appears on the map. When CallOutAnnotation view appears on the map, the custom Button and label appear over the CallOutAnnotation view. I have tried a lot more things but they don't go to back of CallOutAnnotation view. need help.
Thanks and regards,
PC
If I understood it correctly, you've placed a label and a button over your map, which is pretty much the problem you're having.
What happens now is that any subviews added to your mapView are automatically below your label and a button. You could try adding them as subviews to your map (I'm not sure if this will work), but probably the best way to go around this is to place the button and the label somewhere less out of the way.
You could always try changing the alpha of the button and the label to 0 when you want them to be hidden then back to 1 when they should reappear.
button1.alpha = 0;
You can even animate this if you want to:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
//enter code
[UIView commitAnimations];
Hope it helps!

How is the purchase button animation made in the Apps Store?

I've tried creating two UIButtons programatically as described here. This works great but there doesn't seem to be a simple transition for expanding the UIButton on the left as seen in the Apps Store.
If you would like to animate the size of your button, you can use transforms or make the frame larger. Just set the new frame or transform, start the animation, and your button should animate to it's new size.
Assuming your button starts as 50 wide, 38 high and is at the 100,100 point of the screen:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.5];
yourButton.frame = CGRectMake(70, 100, 80, 38); // this makes the button 80 wide, expanding to the left
//here you can change other values, such as the background image and title.
[UIView commitAnimations];