I want to slide a transparent menu in from the left - objective-c

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];
}

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

Rotating One UIView Causes Another To Be Pushed OffScreen

I have a ViewController which contains a couple of UILabels, a UIImageView and an ADBannerView. There are two relevant movements: The UIImageView rotates based on the angle at which the user is holding their device, and the ADBannerView slides into view based on whether it has an iAD to display.
If the UIImageView is stationary, the ADBannerView slides into view correctly. However, once the UIImageView starts rotating, the ADBannerView disappears. AFAIK the two views are completely independent.
- (void) updateFloatingBar
{
double angleToUpright = [self calculateAngleToUpright];
double newAngle = angleToUpright - self.currentAngle;
[self.FloatingBarImageView setTransform:CGAffineTransformMakeRotation(newAngle*(CGFloat)(M_PI/180))];
}
- (void) hideAd
{
NSLog(#"Ad Hidden");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.adBannerView cache:YES];
self.adBannerView.frame = CGRectMake(0,self.view.bounds.size.height + 50,50,320);
[UIView commitAnimations];
}
- (void) showAd
{
NSLog(#"Ad Shown");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.compassADBannerView cache:YES];
self.compassADBannerView.frame = CGRectMake(0,self.view.bounds.size.height - 50,50,320);
[UIView commitAnimations];
}
Again, the first method works correctly, it just also has the secondary effect of pushing offscreen the adBannerView placed by showAd:

How can I program a custom partial or sub view for a calculator?

I'm building a basic calculator app. The calculator is already fully functional with basic features. The problem I'm having is I ran out of room on the screen to add other, more advanced features. Ideally what I would like to do is create some kind of subclass and view that slides up to to the bottom of the label (where the completed calculations are displayed), when a button on the bottom of the screen is pressed. In other words, I want a view with more operators and computation options to slide up to the bottom of the label and I dont want this view to cover up any digits that are being displayed in the label. Is there anyway to achieve this?
Yes, you can. When your button is pressed, create your new view (with the extra functions), add it as a subview to self.view, and animate a change to it's frame, so that it's frame changes from below the visible view to just below your digits.
Like this:
-(void) buttonPressed {
UIView *myNewView = << create your view >>
myNewView.frame = CGRectMake(0,480, 320,200); // or whatever your width and height are
// 480 means it will be below the visible frame.
[self.view addSubview: myNewView];
float bottom_Y_of_digit_display = 100;// or wherever it is...
[UIView beginAnimations:nil contenxt:nil];
[UIView setAnimationDelay: 0.0];
[UIView setAnimationDuration: 1.0]; // one second.
myNewView.frame = CGRectMake(0,bottom_y_of_digit_display, 320,200);
[UIView commitAnimations];
}
You can use UIAnimations to create an animation out of any changes to UIView properties. You can make your UIView hidden by settings its frame.origin.y to 480 and then change the rect and wrap it in a UIAnimation.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
CGRect newFrame = newSubView.frame;
newFrame.origin.y -= newSubView.frame.size.height;
newSubView.frame = newFrame;
[UIView commitAnimations];
UPDATE
If you are targeting iOS 4.0 and later then you should use the new UIAnimations interface.
UIViewAnimationOptions options = UIViewAnimationOptionCurveLinear;
[UIView animateWithDuration:0.75 delay:0 options:options
animations:^(){
CGRect newFrame = newSubView.frame;
newFrame.origin.y -= newSubView.frame.size.height;
newSubView.frame = newFrame;
}
completion:^(BOOL finished){
//Do something upon completion
}];

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];

UIButton Buy Now effect

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