How to Add popover Animation on UIView in iPhone - iphone

I have a Button Add. which will add images from Gallery and Camera.
I want to show this UIVIew from ryt corner and it will expand from 1 to 2 to 3 and to final stat 4. like a baloon . and it will hide as same, from 4 to 3 to 2 to 1.
I have used this animation but this is not what i want ( balloon popover)
/*[UIView beginAnimations:#"" context:NULL];
//The new frame size
[AddImagesToCanvasView setFrame: CGRectMake(224,185,175,132)];
//The animation duration
[UIView setAnimationDuration:2.0];
[UIView setAnimationDelay: UIViewAnimationCurveEaseIn];
[UIView commitAnimations];*/

just change the frames and radious which you want.. also add image in background if you want to display like a ballon with ballon image see code..
UIView *popUpView = [[UIView alloc] initWithFrame:view1.frame]; ///add the frame with requirement e.g view1,view2
popUpView.alpha = 0.0;
popUpView.layer.cornerRadius = 5;
popUpView.layer.borderWidth = 1.5f;
popUpView.layer.masksToBounds = YES;
[self.view addSubview:popUpView];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4];
[popUpView setAlpha:1.0];
[UIView commitAnimations];
[UIView setAnimationDuration:0.0];
UPDATE:
also see the custom popover view from bellow link..
PopupView
alpopoverview
i hope this help you...

Related

How to add a subview with drag in animation from top of the view, in iOS?

I need to add a UIDatePicker subview on a button click to my main view.
How can I add the view with animation such that the subview flips in from the top of the main view and on removing ,undergoes the reverse animation ? I know the subview can be added in a frame that is outside the visible area of the view and then moving it to visible area using CABasicAnimation will be abetter choice. So need help regarding the animation block that I should use.
Thanks in advance
Try this bellow code... here if yourView default frame with origin y = -500 then try bellow code on any UIButton click event.. also set frame which you want
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
CGRect frame = yourView.frame;
frame.origin.y = frame.origin.y + 500; // give any value for display yourView
yourView.frame = frame;
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:yourView cache:YES];
[UIView commitAnimations];
Use CATransaction for animation.

Build a custom share panel of buttons

I am trying to build a custom share panel with buttons.
This is how it appears before being clicked.
This is how it appears after.
I know that may be complicated, but I need the steps to accomplish this.
The images show the mock-ups of the panel.
You just think complicated. It is not complicated; all you need is a view on the main window with this arrow custom button, when click it just move it from bottom to top.
I found the solution.
Create the user interface.
Link the user interface with IBoutlets and IBActions.
Animate the UIView item with buttons.
-(IBAction) openPanelBtnPressed:(id)sender{
CGPoint wpos = self.panel.frame.origin ;
if(wpos.x == 0 && wpos.y ==133){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
self.panel.frame=CGRectMake(0.0,330, 76, 368);
self.panel.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
UIImage * imgOpenPanelBtn = [UIImage imageNamed:#"up.png"];
[self.btnOpenPanel setImage:imgOpenPanelBtn forState:UIControlStateNormal];
}else {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
self.panel.frame=CGRectMake(0.0, 133.0, 76, 368);
self.panel.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
UIImage * imgOpenPanelBtn = [UIImage imageNamed:#"down.png"];
[self.btnOpenPanel setImage:imgOpenPanelBtn forState:UIControlStateNormal];
}
}
The result is this one: http://www.youtube.com/watch?v=6zoZKjbZAps.
You can find the explanation in Arabic on my blog.
You can download the project.

uiview CGAffineTransform animates backwards

I have a UIView subclass which I am able to successfully use UIView animations on.
This UIView also has subviews, which I also want to be able to UIView animate.
However, it seems that whenever I create an animation and apply it to the parent view it works fine, but if I apply the animation to the child view it animates backwards.
For example, if I scale my UIView parent(self) by a factor of 2 (to double the width and height):
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration:2];
[UIView setAnimationDelay:2];
CGAffineTransform scaleTransform = CGAffineTransformScale( self.transform, 2, 2 );
self.transform = scaleTransform;
[UIView commitAnimations];
then this works fine.
But if I do the same on the child:
UIView *myObj = [[self subviews] objectAtIndex:0];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration:2];
[UIView setAnimationDelay:2];
CGAffineTransform scaleTransform = CGAffineTransformScale( myObj.transform, 2, 2 );
myObj.transform = scaleTransform;
[UIView commitAnimations];
It doesn't work. What happens visually is that the child view immediately shrinks down and then after the delay scales back up to it's original size.
If I log the transform parameters it looks the same for both parent and child and I have tried setting CGAffineTransformIdentity.
Any ideas what might be the problem?
I was overriding layoutSubviews and in there I was assigning sizes/positions of the views based upon device orientation which was conflicting.doh!

iPhone xCode | Slide a UIView

How can I make a transition from a UIView to other, like a slide from left or right ?
In addition to PageControl, refer ScrollViewSuite, Scrolling and PhotoScroller. Read the developer documentation for UIScrollView, you wouldn't have had to ask this question.
Write something like this.
[UIView beginAnimations:#"" context:NULL];
//The new position for view1
[myview1 setFrame: CGRectMake(0,0,320,100)];
//The new position for view2
[myview2 setFrame: CGRectMake(320, 0, 320, 100)];
//The animation duration
[UIView setAnimationDuration:2.0];
[UIView setAnimationDelay: UIViewAnimationCurveEaseIn];
[UIView commitAnimations];

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!