UIButton Buy Now effect - objective-c

I want to make a "Buy Now" button in my Application, which should work the same way as the one in the App Store, but I dont know how to resize the UIButton with an animation.
I have tried the following, but it resized the button at once and not as an animation:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:10.5];
[buyButton setFrame:CGRectMake(20, 115, 70, 21)];
[UIView commitAnimations];
Where the "buyButton" is a UIButton.
I've checked ou this post UIButton AppStore buy button animation, but is does not seem to work.

Try this:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:duration];
CGAffineTransform scale = CGAffineTransformMakeScale(scalingFactorX, scalingFactorY);
buyButton.transform = scale;
[UIView commitAnimations];
Using CGAffineTransform may help. I have not tried this, however, it should work.

the sample code on theapptree.com for the inapp purchase should do what you want.
http://www.theapptree.com/samples

Related

How to flip two views Objective C iOS 13

I have two views that flip (like Turing over a card horizontally). iOS 13 has depreciated the begin animations code and I'm trying to figure out how to use [UIView animateWithDuration:delay:options:animations:completion:]
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.ABCard cache:YES];
[self.ABCard exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
I'm trying to do the following but the animation just switches views instantly with no flip action.
[UIView animateWithDuration:1.0 delay:1.0
options: UIViewAnimationCurveEaseInOut | UIViewAnimationTransitionFlipFromLeft
animations:^{
[self.ABCard exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
} completion:^(BOOL finished){
}];
exchangeSubviewAtIndex doesn't change the look of the animation so it's won't result in an animation, which is why you just see it flip.
Results from this answer may help you with a proper solution: iPhone Flip Animation using UIViewAnimationTransitionFlipFromLeft in landscape mode

I want to slide a transparent menu in from the left

I would like to implement a menu as shown above. I'm a total iOS newbie. I've been searching for that kind of control since couple of days.
Can someone guide me step by step, from scratch?
You can implement the above in following steps :-
1>Left Menu view is a UIView added as a subview with various cutom UIButtons over it added as subview.
2>Initially you have to set the frame so that only a particular part of the view is shown(Panel Part).
3> On the click of indicator button , expand the frame to its full to show the buttons.
4>On next click i.e(odd clicks) collase the frame.
Above animation can be achieved using simple UIView Animation.
Sample code(Original frame width=300,Height 300) :-
yourMenuView.frame=CGRectMake(0,10,100,300);
[yourViewController addSubview:yourMenuView];
-(IBAction)expandMenu:(id)sender
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
CGRect frame=yourMenuView.frame;
frame.size.width+=200;
yourMenuView.frame=frame;
[myview removeFromSuperview];
[UIView commitAnimations];
}
-(IBAction)collapseMenu:(id)sender
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
CGRect frame=yourMenuView.frame;
frame.size.width-=200;
yourMenuView.frame=frame;
[myview removeFromSuperview];
[UIView commitAnimations];
}

Can I horizontal filp the UIButton?

I've some problem with UIButton.
In my case I have to flip the button horizontally.
I tried it's width to minus value. But it doesn't work.
How can I do this?
Simply set its transform to CGAffineTransformMakeScale(-1.0, 1.0).
If you want it to rotate 360 degrees horizontally:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75]; // transition speed
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.YourButton cache:NO];
[UIView commitAnimations];

Stop user interaction on view

My code does an animation that flips from right to left. The problem is while its switching, only a .75 second animation, the user is still able to interact with the program. I dont want them to be able to, is there a way to stop all user interaction for a short time, or just a way to stop it completely, then i can just use a timer to put it back on. here is my code for the animation:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:[self view]
cache:YES];
[UIView commitAnimations];
Thanks, Jacob
Try:
[self.view setUserInteractionEnabled:NO];

swapping views with cool page turn animation

Below is code that I'm using to swap views
MySecondViewController *tempVC = [[MySecondViewController alloc] initWithNibName:#"MySecondView"];
[self presentModalViewController:tempVC animated:YES];
[tempVC passDataWithString:#"a string" andColor:yellowcolor];
How can I get the cool page turning animation (as with iBook or ROAD RAGE SIGN)
I don't want the user to actually tap and drag his finger on the screen. I want him to push a button and the animation occurs by itself.
Have you looked at UIViewAnimationTransition values? Use them in a UIView animation block. eg:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition: UIViewAnimationTransitionCurlUp
forView:self.view cache:YES];
[UIView commitAnimations];