I use the code below to scale my view when event happen. But I want the view to be enlarged or reduced with animation not directly see the scaled result. How can I achieve that effect?
view.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor)
You can use UIViewAnimations
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
view.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor);
[UIView commitAnimations];
You could also use a block animation.
[UIView animateWithDuration:0.3 animations:^{
view.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor)
}];
Related
I have customized the UIViews by adding images to make it look like radio button or check boxes, but for my spec I want to make the UIAlertView look like this...
Can anyone suggest how to do this?
Thanks!
You can design custom view and can give animation to it as alert view using this code
-(void)initialDelayEnded
{
alert_upload.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
alert_upload.alpha = 1.0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1/1.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(bounce1AnimationStopped)];
alert_upload.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
[UIView commitAnimations];
}
- (void)bounce1AnimationStopped {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5/2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(bounce2AnimationStopped)];
alert_upload.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
[UIView commitAnimations];
}
- (void)bounce2AnimationStopped {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5/2];
alert_upload.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
}
alert_upload is UIView.
There’s many previous questions about this topic, one of them links this component that lets you create custom alerts and action sheets. Might be a good way to start.
You can create your own customized alert views, Apple wont reject it until unless user interaction.
I'm animating two uiviews using CGAffineTransform
For 1st view:
swingView.transform = CGAffineTransformRotate(swingView.transform, M_PI/2);
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse
animations:^{
swingView.transform = CGAffineTransformMakeRotation(M_PI);
}
completion:^(BOOL finished){
NSLog(#"Done!");
}];
For second view
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationBeginsFromCurrentState:YES];
CGAffineTransform transform = CGAffineTransformMakeTranslation(touchLocation.x, touchLocation.y);
CGAffineTransform transform1 = CGAffineTransformMakeTranslation(-120, 0);
myview.transform = transform1;
[UIView commitAnimations];
Here two views are hitting when animation starts, what i have to do to not allow hitting between these uiviews.
I want to apply animation on UILabel text. I write the code to increase font size in animation block but animation is not applied.
[UIView beginAnimations:nil context:nil/*contextPoint*/];
monthsOnBoard.font=[UIFont fontWithName:#"digital-7" size:150];
daysOnBoard.font=[UIFont fontWithName:#"digital-7" size:150];
hoursOnBoard.font=[UIFont fontWithName:#"digital-7" size:100];
minutesOnBoard.font=[UIFont fontWithName:#"digital-7" size:100];
secondsOnBoard.font=[UIFont fontWithName:#"digital-7" size:100];
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:0.5];
[UIView setAnimationDuration:1];
[UIView setAnimationRepeatCount:4];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView commitAnimations];
The font of a UIView is not an animatable property. You should use transforms instead.
[UIView beginAnimations:nil context:nil/*contextPoint*/];
monthsOnBoard.transform = CGAffineTransformMakeScale(2.0, 2.0); //increase the size by 2
//etc etc same procedure for the other labels.
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:0.5];
[UIView setAnimationDuration:1];
[UIView setAnimationRepeatCount:4];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView commitAnimations];
similarly, you can play with the values in CGAffineTransformMakeScale(x, y); - x is the horizontal scale constant and y is the vertical one. Enjoy!!
it may be help you
monthsOnBoard.transform = CGAffineTransformScale(monthsOnBoard.transform, 1, 1);
[UIView beginAnimations:nil context:nil/*contextPoint*/];
monthsOnBoard.transform = CGAffineTransformScale(monthsOnBoard.transform, 4, 4);
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:0.5];
[UIView setAnimationDuration:1];
[UIView setAnimationRepeatCount:4];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView commitAnimations];
Well I would like to have two UIView animation on a same image in the same method like this :
-(void)likeThis{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
image.alpha=0;
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
image.transform = CGAffineTransformScale(5,5);
[UIView commitAnimations];
}
But there is only one of these UIView Animation who work.I don't know why.I think there is another way to put two animation for the same image but I don't know how. sorry for my english I'm french :/
You can just put them in the same animation block:
-(void)likeThis
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
image.alpha=0;
image.transform = CGAffineTransformScale(image.transform,5,5);
[UIView commitAnimations];
}
Note that CGAffineTransformScale takes three arguments:
CGAffineTransformScale(image.transform, 5.0, 5.0)
See http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGAffineTransform/Reference/reference.html#//apple_ref/doc/uid/TP30000946-CH1g-F16985
Or you could use CGAffineTransformMakeScale:
http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGAffineTransform/Reference/reference.html#//apple_ref/c/func/CGAffineTransformMakeScale
Do you want them to happen simultaneously, or one after the other? If the former just include them both between a single set of beginAnimations..commitAnimations calls
I am wondering how I would go about animating a UIView's to a specific CGPoint. The following is what I have so far (which doesn't work in it's current state):
#define MOVE_ANIMATION_DURATION_SECONDS 2
NSValue *pointValue = [[NSValue valueWithCGPoint:point] retain];
[UIView beginAnimations:nil context:pointValue];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:MOVE_ANIMATION_DURATION_SECONDS];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
Try:
#define MOVE_ANIMATION_DURATION_SECONDS 2
[UIView beginAnimations:nil context:pointValue];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:MOVE_ANIMATION_DURATION_SECONDS];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(animationDidStop:finished:context:)];
CGRect frame = myUIViewObject.frame;
frame.origin = point;
myUIViewObject.frame = frame;
[UIView commitAnimations];
After the begin, but before the commit, change the value on your UI View.
If you're targeting 10.5 or above, you can use Core Animation via the animator proxy added to NSView. Try
[[someView animator] setFrame: someNewFrame];