iPhone effect hide slow object - iphone

i've a problem : in my app i've a UISlider. Its function is to set the volume of some files i've included. I want to do this thing : the slider will be hide when user tap the screen and will be not hide when the user retap the screen. But there were 2 problems :
1.- i want to use a slow hide effect, not from .alpha=0.0 to .alpha=1.0, but gradually
2.- i don't know what to do if user tap the screen when slider is going to hide or to show
Sorry for my english, i'm italian :)
Thanks

Use animations
// To hide the slider slowly
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
slider.alpha = 0.0;
[UIView commitAnimations];
// To show the slider
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
slider.alpha = 1.0;
[UIView commitAnimations];

Related

animate an image like cardiogram

i have an image
i want to animate this image continuously i.e entering from left end of screen and exit at right end for this i'm using this code..
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:15];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
cardioImage1.frame = CGRectMake(330, 0, 320, 100);
[UIView commitAnimations];
This code animate images only for one time.
I want to make it continuous animation for certain time frame.
What can i do for that... please help me.
Thanks in advance.
You need to set some value to this property :
setAnimationRepeatCount
Perhaps use FLT_MAX for infinite loop

Programmatically zoom in and out in iPhone: how can i set animation speed?

I have an app where i would like to dynamically zoom in and out an imageView.
I use [scrollView zoomToRect:CGRectMake(x,y,z,k) animated:YES]; to zoom in but i would like the animation to be slower ... is there a way to set the animation speed?
see my other answer. You can set the animation duration to something like 1.0 second.
instead of:
cursorView.center = locationOfTouch;
you have to set:
[UIView beginAnimations:nil context:NULL]
[UIView setAnimationDuration:1.0];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[scrollView zoomToRect:CGRectMake(x,y,z,k) animated:NO]; // NO is necessary!
[UIView commitAnimations];

How to present a modalView just above the control which makes it pop up?

How can I create a modal to pop up just above the button clicked?
As shown here above in the image, the pop up is just above the button "sleeping like a baby".
I want the modal to pop up in a similar way.
How can I do that?
you can do it by changing the frame of your popup view with animation as -
[popUpView setFrame:];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[popUpView setFrame:];
[UIView commitAnimations];

UIView cancel animation

I currently have a view animating from one part of the screen to another. I want the animation to pause whenever the "pause" button is pressed. This means the animation needs to remain right where it is (frame location) when I "pause" the animation. I've tried a few things but nothing has given me the result I want. Below is a rough version of my current code.
-(IBAction)startScroll
{
NSLog(#"Start scroll");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:30];
//set new frame for view
[UIView commitAnimations];
}
and one method to stop the animation
-(IBAction)pauseScroll
{
NSLog(#"Pause Scroll");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:0.1];
//Pause animation in it's current location
[UIView commitAnimations];
}
Ended up going with a timer and updating the contentOffset every few seconds. Wish there was a better way to get a view current coords even during an animation. The presentationLayer stuff did not yield successful results.
UIView animations don't quite work like that. Once you set the frame, the view instantly moves there from your app's perspective; it's just the display to the user that's animated.
You can use the "presentation layer" to figure out roughly what's being displayed on screen (it's only approximate since the compositing happens in another thread):
#import <QuartzCore/CALayer.h>
...
[fooView setFrame:fooView.layer.presentationLayer.frame]

how to implement an iPhone view transition animation with both flipping and scaling?

how can I implement the animation we see in the iPhone Music app's coverflow screen? when you click on a small view, it flips and scales up to another view? how can I do this? I can use core animation to flip and scale a view, but how can I do the transition to another view? thanks
You need an UIView as Container for the two UIViews (frontside/backside) and then remove/add these from/to the container as subviews while doing the animations in between:
UIView *flipContainer;
UIView *frontSide;
UIView *backSide;
//...
-(void)turnUp
{
[backSide removeFromSuperview];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:flipContainer cache:YES];
[UIView setAnimationDuration:1.0];
CGAffineTransform transform = CGAffineTransformMakeScale(1.2, 1.2);
flipContainer.transform = transform;
[UIView commitAnimations];
[flipContainer addSubview:frontSide];
}
-(void)turnDown
{
[frontSide removeFromSuperview];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:flipContainer cache:YES];
[UIView setAnimationDuration:1.0];
CGAffineTransform transform = CGAffineTransformMakeScale(1, 1);
flipContainer.transform = transform;
[UIView commitAnimations];
[flipContainer addSubview:backSide];
}
I'm trying the exact code you are doing - I get a zoom effect but no turn over. The only difference is that right before the turnUp code I add the flipContainer (with back showing) so then it can be flipped over.
// construct animation container
self.flipContainer = [[FlipContainer alloc] init];
[self.flipContainer.view setFrame:CGRectMake(clickedSquareX, clickedSquareY, 200, 200)];
[self.flipContainer.view addSubview:self.backside.view];
// add animation container
[self.myParentView.view addSubview:self.flipContainer.view];
// PROCEED to your turnUp code
The reason I'm doing this is I have a bunch of images in a horizontal UIScrollView and so to 'simulate' a 200x200 image flipping over and zooming to show detail I add my flipContainer with the backside showing the exact image over the exact spot of the pressed image. It should work shouldn't it? A bit confusing to me is the first line of your turnUp code you do:
[backSide removeFromSuperview];
..which would remove the view I just added.
I'm not sure if this is the right spot to put this question in - sorry if it isn't!