UIView Animation IOS - ios

Possible so many duplicates of this question , but i didn't find any solution.
I want to slide up my view when user slideup gesture
here is my scenario
https://app.box.com/s/unt3gyahpx0ax187c5rv
Custom Tabbar is on Top and below is view whci can be slide up/down.
Here is my animation code.
[UIView transitionWithView:self.topView duration:10 options:UIViewAnimationOptionTransitionNone animations:
^{
self.topView.frame = CGRectMake(0,-300,1024,141);
}
completion:^(BOOL finished){}];
But the output is
https://app.box.com/s/fjm1x081jcex1916wyne
I want to slide this view behind the custom tabbar.
I hope you understand my problem.

Related

Navigation drawer- sliding issue in ios

I am trying to create a sliding menu (like the one in google maps app) in which menu screen should be shown or added as subview over the existing screen on tapping a button. While showing it, the sub view should be animated from left to right. I tried to animate while adding it as subview, but failed in doing so. Can any one suggest how to do it? (or) Can I do it using navigation controller?
Thanks in advance!!
You need to add the subview, and set it's frame out of the screen.(320,0,100,568 for example).
Of course it's better to use auto layout for that.
Add as subview:
[self.view addSubView:sideMenu];
When you want to show it, just change it's frame using animation block.
[UIView animateWithDuration:0.2 delay:0.1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
sideMenu.frame = CGRectMake(220,0,100,568);
} completion:^(BOOL finished) {
}];
As I said, it's better to use auto layout and not setting frames. I did it only for the example.

How do I see the progress of a pop animation?

I have a master and detail view controller. I have a button that currently disappears after the push segue to the detail and reappears when the pop segue is called, whether it's the interactive gesture or the back button.
This looks really abrupt and I wanted to fade in the alpha on the button with the pop gesture but I don't see any delegate or datasource methods for UINavigationControllerDelegate that show the progress of the pop gesture. Are there any libraries that help with this?
This can be accomplished with a UIView animation.
The idea is to set the alpha of the button to 0 so that it is invisible and then animate it to a value of 1 to create a fade-in effect.
self.myButton.alpha = 0;
[[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
self.myButton.alpha = 1;
} completion:^(BOOL finished) {
// Code for completion of animation.
}];
This could be placed in the viewDidAppear: method of your view controller.

Hidding view with table scroll

I'm searching for idea how to implement a table view with moving view on top of it.
So the idea is something similar to navBar in facebook app. When you scroll up this (red) view is moving up and hiding, when you scroll up its going up and when you scroll down its revealed. This is not nav bar so most of the pods I've found are not working in this situation. This cannot be tableView header or section header as well.
You need added this view above table:
[self.tableView.superview insertSubview:view aboveSubview:self.tableView]
Or you can do it in storyboard.
When you table scroll down hide view, when up show.
[view setHidden:YES];
Also u could change table inset to the top of the superview.
self.tableView.contentInset = self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(self.tableView.contentInset.top -, self.tableView.contentInset.left, self.tableView.contentInset.bottom, self.tableView.contentInset.right);
I think fast way to do it use gesture recognizers to recognize reveal and hide actions and than you can use methods like below,
[UIView animateWithDuration:0.5 animations:^{
[attachedView setAlpha:0.0f];
} completion:^(BOOL finished) {
[attachedView setHidden:YES];
}];
and for reveal attached view
[UIView animateWithDuration:0.5 animations:^{
[attachedView setAlpha:1.0f];
} completion:^(BOOL finished) {
[attachedView setHidden:YES];
}];
methods will help you to hide and reveal views gently.
Take a look at this library, it does exactly what you want to do
https://github.com/telly/TLYShyNavBar

How to translate an entire UIView and retain gesture recognition?

I have a UIView "MainView" that initially appears as follows:
The gradient bar is part of MainView, the whitespace beneath is part of a Container View subview.
When the search button in top-right is tapped, I animate a searchBar from offscreen to be visible in the view:
I manage to do this by the following code:
CGRect currentViewFrame = self.view.bounds;
currentViewFrame.origin.y += searchViewHeight;
[UIView animateWithDuration:0.4
delay:0.0
usingSpringWithDamping:1.0
initialSpringVelocity:4.0
options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.view.frame = currentViewFrame;
}
completion:^(BOOL finished)
{
}];
Visually, the result of this animation is perfect. The entire view shifts, and the searchBar is now on screen. However, the searchBar does not respond to interaction. Correct me if I'm wrong, but I expect this is because the MainView's frame no longer includes the screen area that the searchBar now occupies, so its effectively a gesture deadzone.
So this makes me think that instead of lazily animating the entire MainView down to accomodate the searchBar, I must instead individually translate all subviews of MainView one at a time. In this simple situation, that would not be a big problem, but I can envision a circumstance with tens of subviews making that completely unrealistic.
What is the best method to accomplish what I am trying to do? Is there a secret to animating entire views/subviews without having gesture deadzones? Thanks in advance!!

How to do a horizontal cover segue using storyboards?

There is a vertical cover transition. I have been looking around the web for how to do a horizontal cover with no success. Any suggestions?
There's no horizontal cover transition provided in iOS. You'll have to create your own UIStoryboardSegue subclass and implement your own transition animation.
One way to animate the kind of transition I think you're looking for is something like this (warning: untested code):
// add newView to window
[oldView.window insertSubview:newView aboveSubview:oldView];
// assuming newView and oldView both sized to fill screen,
// position newView just to the right of oldView
newView.center = oldView.center + oldView.frame.size.width;
// slide newView over oldView, then remove oldView
[UIView animateWithDuration:0.3
animations:^{ newView.center = oldView.center; }
completion:^(BOOL finished){ [oldView removeFromSuperview]; }];
When you use a navigation controller and then push and pop views from it the effect is a horizontal cover.
As answered by T.J. above, use a navigation controller and it will default to horizontal cover automatically.

Resources