I have a location button. I want to open a pop up view when location button got pressed. like this
when this view opened, all buttons and background view should be blurred.
How can i achieve this??
thnx for any kind of help.
To show the view with alert like animation create a popView you want to show and follow the below code:
popView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
[self.view addSubview:popView];
[UIView animateWithDuration:0.3/1.5 animations:^{
popView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3/2 animations:^{
popView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3/2 animations:^{
popView.transform = CGAffineTransformIdentity;
}];
}];
}];
popView.transform = CGAffineTransformIdentity;
Hide the other views visible.
Just follow the below code
-(IBAction)buttonPress:(id)sender
{
popView.hidden = NO;
//OR
[self.view addSubview:popView];
btn1.hidden = YES;
btn2.hidden = YES;
btn3.hidden = YES;
view1.hidden = YES;
}
Simple,
Create one view & size of that view will be size of parent view. Your second view will contain your UI along with black blur view at background.
When you tap on the location button display that view so all other button will be hidden automatically.
Related
How to animate the expansion of a UICollectionViewCell's content upon selection?
Currently I'm using transition animation on my didSelectItemAtIndexPath for animating a view Which isn’t working smoothly like AppStore card animation.
Here is my current code...
AnimateStaticImageViewController *animateImageVC = [[AnimateStaticImageViewController alloc] init];
animateImageVC.modalPresentationStyle = UIModalPresentationFullScreen;
animateImageVC.modelImage = [UIImage imageNamed:text];
[UIView animateWithDuration:0.7 animations:^{
animateImageVC.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.3);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.7 animations:^{
animateImageVC.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.7 animations:^{
animateImageVC.view.transform = CGAffineTransformIdentity;
}];
}];
}];
[self presentViewController:animateImageVC animated:NO completion:nil];
So, I was trying a modal transition animation in my app's home page staticImageCollectionView immediately after clicking the image.
The core animation & transform mechanism didn't work for me as I need something like AppStore's card animation.
Using this library worked after some hassle! Following this...
Setting the library with following steps.
Calling the transitioningDelegate of the animationViewController on didSelectItemAtIndexPath (or prepareForSegue if working with segue-navigation controller).
Calling it within a completion block to ignore flickering & delay issue in view presentation.
AnimatedStaticImageViewController *animateImageVC = [[AnimatedStaticImageViewController alloc] init];
animateImageVC.modalPresentationStyle = UIModalPresentationFullScreen;
animateImageVC.modelImage = [UIImage imageNamed:text];
[UIView animateWithDuration:0.2
animations:^{
animateImageVC.transitioningDelegate = self;
} completion:^(BOOL finished) {
[self.view removeFromSuperview];
[self presentViewController:animateImageVC animated:YES completion:nil];
}];
Be careful when setting imageView which is the main presentation of the animation.
Make sure you declaring the delegate 'RMPZoomTransitionAnimating' & 'RMPZoomTransitionDelegate' methods on both fromViewController and toViewController.
I want to make an Menu Animation just as shown below.
I need to have UIButtons inside the menu.
How can i achieve this.
for this animation you should set anchor point by default the anchor point position is (0.5,0.5), so can change the anchor point position:
All geometric manipulations to the view occur about the specified point. For example, applying a rotation transform to a layer with the default anchor point causes the layer to rotate around its center. Changing the anchor point to a different location would cause the layer to rotate around that new point.
self.view.layer.anchorPoint = CGPointMake(0,0);
self.view.transform = CGAffineTransformMakeScale(0.001,0.001);
[UIView animateWithDuration:1.0 animations:^{
self.view.transform = CGAffineTransformIdentity;
}];
Please add the follow code on button click:
[UIView animateWithDuration:1
animations:^{
myView.transform = CGAffineTransformMakeScale(1.5, 1.5); }
completion:^(BOOL finished) {
[UIView animateWithDuration:1
animations:^{
myView.transform = CGAffineTransformIdentity;
}]; }];
It will work for you.
Create Super class SuperViewController.m
Add this method
- (void)viewDidLoad {
[super viewDidLoad];
//Here u can set image also in navigation bar
UIBarButtonItem *buttonC = [[UIBarButtonItem alloc]initWithTitle:#"Word" style:UIBarButtonItemStylePlain target:self action:#selector(GeTVAlue)];
[self.navigationItem setLeftBarButtonItem:buttonC];
}
-(void)GeTVAlue{
UIView *paintView=[[UIView alloc]initWithFrame:CGRectMake(-350, -350, 350, 350)];
[paintView setBackgroundColor:[UIColor yellowColor]];
[self.view addSubview:paintView];
[UIView animateWithDuration:1
animations:^{
paintView.transform = CGAffineTransformMakeScale(2.5, 2.5); }
completion:^(BOOL finished) {
[UIView animateWithDuration:1
animations:^{
paintView.transform = CGAffineTransformIdentity;
}]; }];
}
Then Inherit your Super class in your class
#interface TheerdViewController : SuperViewController
If u have any question fill free ask me.
Thnak you
This is a continuation of this question
CGRectMake : How To Calculate X and Y For UIPickerView Animation?
answered by https://stackoverflow.com/users/2315974/danypata
I have a picker view that I want to animate on and off screen on a button press and using the code in the previous question/answer I have got it to animate on screen the first time the button is pressed.
the second tome the button is pressed it just disappears and then the third time it is pressed it animates to the wrong place...please help
the code
if (self.pickerSort.hidden == NO) {
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
self.pickerSort.frame = CGRectMake(0,self.view.frame.size.height
+ self.pickerSort.frame.size.height,-self.pickerSort.frame.size.width,-self.pickerSort.frame.size.height);
}
completion:^(BOOL finished) {
}];
self.pickerSort.hidden = YES;
// [self performSelector:#selector(hidePicker) withObject:nil afterDelay:1];
} else if (self.pickerSort.hidden == YES) {
self.pickerSort.hidden = NO;
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
self.pickerSort.frame = CGRectMake(0 ,
self.view.frame.size.height
- self.pickerSort.frame.size.height,
self.pickerSort.frame.size.width,
self.pickerSort.frame.size.height);
}
completion:^(BOOL finished) {
}];
[self.view bringSubviewToFront:self.pickerSort];
Behavior in images - button press animates onto screen beautifully
Second Press it disappears with no animation
Third Press it animates to here
Any help would be great...functionality I am looking for is how to put the picker view back on an animation so the 3rd press is the same as the first
Please try to use the below code.
self.pickerSort.hidden = NO;
NSTimeInterval duration = 0.5;
[UIView animateWithDuration:duration
delay:0
options:UIViewAnimationOptionCurveLinear
animations:^{
CGRect pickerFrame = self.pickerSort.frame;
// currently picker is off the screen, show it.
if (pickerFrame.origin.y == self.view.frame.size.height) {
// set frame to show picker
pickerFrame.origin.y = self.view.frame.size.height - self.pickerSort.frame.size.height;
} else {
// set frame to hide picker
pickerFrame.origin.y = self.view.frame.size.height;
}
self.pickerSort.frame = pickerFrame;
}
completion:^(BOOL finished) {
self.pickerSort.hidden = YES;
}];
After playing around with this and learning the ins and outs of frames and CGRects, I achieved this by using the following code
if (pickerSort.hidden == YES) {
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
pickerSort.hidden = NO;
visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[self.tableStations addSubview:visualEffectView];
pickerSort.frame = CGRectMake(0,0,originalPickerFrame.size.width,originalPickerFrame.size.height);
visualEffectView.frame = CGRectMake(0,0,originalPickerFrame.size.width,originalPickerFrame.size.height - 64);
}
completion:^(BOOL finished) {
self.navigationController.navigationItem.leftBarButtonItem.enabled = NO;
}];
}
else
{
visualEffectView.hidden = YES;
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
pickerSort.frame = CGRectMake(0,-originalPickerFrame.size.height,0,0);
}
completion:^(BOOL finished) {
self.navigationController.navigationItem.leftBarButtonItem.enabled = YES;
pickerSort.hidden = YES;
}];
}
I set the original frame size in viewDidLoad like so
pickerSort = [[UIPickerView alloc]initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height)];
originalPickerFrame = pickerSort.frame;
pickerSort.frame = CGRectMake(0,-originalPickerFrame.size.height,0, 0);
Hope this can help somebody in the future
i have a line separator of master and detail view(ipad) and stay always appeared when touching a textview , is that a way to make always the popup in front ?thanks..
for that you have to Create one UIView & Use like ,
//For Set Alert View
[[self.view superView] bringSubviewToFront: YOurCreatedView];
& for Dismiss Alert View
[[self.view superView] sendSubviewToBack: YOurCreatedView];
And For Animation Use below Method..
[UIView animateWithDuration:0.25 animations:^{
//
} completion:^(BOOL finished) {
//
}];
or Below Method..
CATransform3D transform3d = CATransform3DMakeScale(1.15, 1.15, 1.15);
cell.layer.transform = transform3d;
//4. Define the final state (After the animation) and commit the animation
[UIView beginAnimations:#"translation" context:NULL];
[UIView setAnimationDuration:0.8];
[[self.view superView] bringSubviewToFront: YOurCreatedView];
YOurCreatedView.alpha = 1;
YOurCreatedView.layer.transform = CATransform3DIdentity;
YOurCreatedView.layer.shadowOffset = CGSizeMake(0, 0);
[UIView commitAnimations];
With the following code I'm showing a view with an animation on a button click.
UIViewController *modalView = self.pageViewController;
[self.view addSubview:modalView.view];
[UIView animateWithDuration:1 animations:^{
CGRect currentRect = modalView.view.frame;
currentRect.origin.y = 650.0f;
currentRect.size.height = 295.0f;
[modalView.view setFrame:currentRect];
[modalView.view removeFromSuperview];
}];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
This works fine for first time button click. When I'm pressing the button again and again this is not animating anymore. It's animating for the first time only. Is there any way to do so?
Thanks in Advance!
The cause is that modalView.view's frame initially if different from
currentRect.origin.y = 650.0f;
currentRect.size.height = 295.0f;
so when changes its frame animation is happens.
But next time when you perform button's action modalView.view's current frame and that frame you sets are same. So there is nothing to animate at all.
Also, you should move [modalView.view removeFromSuperview]; from animation block to completion block
[UIView animateWithDuration:1 animations:^{
CGRect currentRect = modalView.view.frame;
currentRect.origin.y = 650.0f;
currentRect.size.height = 295.0f;
[modalView.view setFrame:currentRect];}
completion:^(BOOL finished) {
[modalView.view removeFromSuperview];
}];