iPhone: How to hide tab bar to show fullscreen view - iphone

I have gallery view in my iphone app. On tap gesture, I am hiding the Navigation bar by:
[self.navigationController setNavigationBarHidden:activated animated:YES];
I have tab bar also, how to hide it and display the image as full screen?

CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[[self.view.window layer] addAnimation:animation forKey:#"layerAnimation"];
[self.tabBarController.tabBar setHidden:YES];
// Display tab bar animated
CATransition *animation = [CATransition animation];
animation setType:kCATransitionFade];
[[self.view.window layer] addAnimation:animation forKey:#"layerAnimation"];
[self.tabBarController.tabBar setHidden:NO];
I have not checked this code but I think it will work

[[self navigationController] setHidesBottomBarWhenPushed:YES];
i hope this will help you.

self.hidesBottomBarWhenPushed = YES;
this will hide the tabbar

If it a UITabBarController then it has a property tabBar.
tabBarController.tabBar.hidden = YES
should work for you.
Also if your image is not a full size then change the frame of UIImageView to CGRectMake(0, 0, 320, 460); if you are showing a status bar.

Related

Transparent view while navigatiing

While navigating from one view to other view, I want to make the second view transparent. i.e. After navigation first view contents should be visible.
I have tried by background color clear and Transparent background images.But on the time of navigation its transparent.
After full navigation the second view back ground becomes black .
Here my code,
obj=[[loginViewController alloc]initWithNibName:#"loginViewController" bundle:nil];
[self presentModalViewController:obj animated:YES];
You can achieve this only if you subview the second view.
By using presentmodalviewcontroller or pushviewcontroller , your firstview will not be visible.
Secondview *second = [[Secondview alloc] initWithNibName:#"Secondview" bundle:nil];
[self.view addSubview:second.view];
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[[self.view layer] addAnimation:animation forKey:#"transitionViewAnimation"];
The solution is to override drawRect: and take care of the alpha in it. You may not touch UIView's alpha property, nor may you set the view's background color to anything bat transparent. All drawing must be made in drawRect:. This way I was able to stack transparent views and pup opaque elements on top.

Fadout multiple image on splashscreen in IOS

I am trying to animate multiple image for splash screen.i am displaying 3 image as splash screen 1st one is default image of splash screen than by using Ui-imageview i am displaying 2nd and 3rd on my Imageview.
I want to fade out image while changing the splash screen. I tried NSTimmer solution but it display me direct 3rd image and maine screen Than after i tried This solution to have but it display me my 2nd and 3rd image 2 times one after another.
any help is appreciated
EDITED /- Nikki Suggest me some solution but i am having confusion that Which place i unhidden my 2nd image view ?
Here is my code
backgroundImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
backgroundImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
backgroundImageView.image=[UIImage imageNamed:#"SPLASHSCREEN-2.png"];
backgroundImageView2 = [[UIImageView alloc] initWithFrame:self.view.bounds];
backgroundImageView2.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
backgroundImageView2.image=[UIImage imageNamed:#"SPLASHSCREEN-3.png"];
[self.view addSubview:backgroundImageView];
[self.view addSubview:backgroundImageView2];
[backgroundImageView2 setHidden:YES];
[self performSelector:#selector(performTransition) withObject:nil afterDelay:1.0];
-(void)performTransition
{
CATransition *animation3 = [CATransition animation];
[animation3 setDuration:3.0f];
[animation3 setType:kCATransitionReveal];
[animation3 setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[backgroundImageView layer] addAnimation:animation3 forKey:#"SwitchToView"];
[backgroundImageView setHidden:YES];
[backgroundImageView2 setHidden:NO];//No animation happen while changing the image view
}
U can create the two ImageView to be displayed in the start and set them hidden at first. Just write the code to animate :
-(void)performTransition
{
CATransition *animation3 = [CATransition animation];
[animation3 setDuration:3.0f];
[animation3 setType:kCATransitionReveal];
[animation3 setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[backgroundImageView2 layer] addAnimation:animation3 forKey:#"SwitchToView"];
[backgroundImageView setHidden:YES];
[backgroundImageView2 setHidden:NO];//No animation happen while changing the image view
}
and set the ImageView will animate while it unhides. The animation type can be changed by changing the values of [animation3 setType:kCATransitionReveal];.
Remember to import : #import<QuartzCore/QuartzCore.h>
for hiding the previous ImageView with animation and displaying next ImageView with animation you can write the code inside a function and can call that function using performSelector and can add desired time interval.

semi page curl animation background view color?

In my project I'm using page animation.
My problem is that I want to show red colour on the background of curled view. How do I achieve that?
Thanks in advance.
CATransition *animation = [CATransition animation];
[animation setDelegate:self]; [animation setDuration:0.75];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
animation.type = #"pageUnCurl";
animation.fillMode = kCAFillModeBackwards;
animation.startProgress = 0.65;
[animation setRemovedOnCompletion:NO];
[[self view] exchangeSubviewAtIndex:[self.view.subviews count]-2 withSubviewAtIndex:3];
[[self view] exchangeSubviewAtIndex:[self.view.subviews count]-3 withSubviewAtIndex:2];
[[[self view] layer] addAnimation:animation forKey:#"pageCurlAnimation"];
This is how I change my view.
This is possible if you use CALayer as the background page when animation is happening.
topPageReverseOverlay = [[CALayer alloc] init];
topPageReverseOverlay.backgroundColor = [[[UIColor redColor] colorWithAlphaComponent:0.8] CGColor];
If you are using layers then when app going to background process then you can loose the curl effect of that particular layer.
If you want complete control over the display of what's behind a partial curl, you can set it as a separate VC. Here's an example:
EndPartialCurlViewController *nextViewController = [[EndPartialCurlViewController alloc] init];
[nextViewController setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[[self navigationController] presentViewController:nextViewController animated:YES completion:nil];
You can then build any color, views, buttons, etc. you want into this EndPartialCurlViewController.
I believe the answer for your question can be found in this thread..
Underside color of curling view using UIViewAnimationTransitionCurlUp
after lot of surfing i found that there is one way by using filters and layes we can achieve this one but that one undocumented method and If you are using layers then when app going to background process then you can loose the curl effect of that particular layer..

Animating transitions of two subviews simultaneously with CATransition

I have my main view, and when a user taps a 'Show' button I want two things to happen:
Fade in a black UIView with alpha 0.5 covering the entire parent
view. I'll refer to this as darkenBackground
Slide the view of a second view controller
(self.secondViewController.view) on top of darkenBackground
When a user is finished, they tap 'Done' and the following happens:
darkenBackground fades out and is removed from the superview.
self.secondViewController.view slides out of the screen in the
bottom direction and is removed from the superview.
All animations working simultaneously.
So far, I've been able to achieve the first part (sort-of), transition-in. This works fine. But when the user taps 'Done' the transition-out does not work as required. The problems I'm faced with are:
darkenBackground and self.secondViewController.view fade out and are removed, but
self.secondViewController.view wasn't supposed to fade out! I tried animating only the second view but it simply disappears without animation.
When a user taps 'Show' for a second time
(transition-in), the view from the previous transition
appears before the animation takes place. It doesn't look like it
was removed from the superview previously.
Here is my code:
When a user taps 'Show':
- (IBAction)showSecondView {
darkenBackground = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 460)];
[darkenBackground setBackgroundColor:[UIColor blackColor]];
[darkenBackground setAlpha:0.5];
self.secondViewController.view.frame = CGRectMake(0, 0, 320, 460);
self.secondViewController.view.backgroundColor = [UIColor clearColor];
[CATransaction begin];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionFade];
CATransition *animation2 = [CATransition animation];
[animation2 setDuration:0.5];
[animation2 setType:kCATransitionMoveIn];
[animation2 setSubtype:kCATransitionFromTop];
[animation2 setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[self.view addSubview:darkenBackground];
[self.view addSubview:self.secondViewController.view];
[[self.view layer] addAnimation:animation forKey:#"darkenBkgFadeIn"];
[[self.secondViewController.view layer] addAnimation:animation2 forKey:#"ShowSecondView"];
[CATransaction commit];
}
When a user taps 'Done' (A function defined in the secondViewController.m class where it refers to the main view controller variables through delegate):
- (IBAction)hideSecondView {
[CATransaction begin];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionFade];
CATransition *animation2 = [CATransition animation];
[animation2 setDuration:0.5];
[animation2 setType:kCATransitionPush];
[animation2 setSubtype:kCATransitionFromBottom];
[animation2 setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[self.myParentController.darkenBackground removeFromSuperview];
[self.myParentController.secondViewController.view removeFromSuperview];
[[self.myParentController.view layer] addAnimation:animation forKey:#"darkenBkgFadeOut"];
[[self.myParentController.secondViewController.view layer] addAnimation:animation2 forKey:#"RemoveSecondView"];
[CATransaction commit];
}
Ultimately I want to show the view in the same way that the TWTweetComposeViewController modal view appears, where the background darkens and the controller appears. I could just use a modal view controller, but the issue I have with that is that when presenting the view controller it only 'appears' and does not slide from the bottom (since I require a semi-transparent background, I cannot use the default context for the modal view).
Cannot figure this one out, would appreciate some guidance.
I assume that self.myParentController.view used in -hideSecondView is the same view as self.view in -showSecondView. If this is the case, then you're applying a transition to the whole view here:
[[self.myParentController.view layer] addAnimation:animation forKey:#"darkenBkgFadeOut"];
You added self.secondViewController.view as a subview of self.view in -showSecondView, so when you later perform a transition on self.myParentController.view, it's going to apply the transition to all its subviews (i.e., self.secondViewController.view) as well.
Instead of applying the transition to self.myParentController.view in -hideSecondView, apply it directly to darkenBackground:
[[self.myParentController.darkenBackground layer] addAnimation:animation forKey:#"darkenBkgFadeOut"];
If I recall correctly, you can apply CATransitions when layers are added/removed to/from a view. If not, then you'll have to wrap darkenBackground in a separate container view and perform the transitions on that so it doesn't include self.secondViewController.view when you do the fade out.

Slide up UIView using kCATransitionPush

I am trying to have a UIView slide up a quarter of the page to reveal another view underneath it (to display options), and then slide back down to cover those options. I've searched SO relentlessly but can't seem to find what I'm looking for. I do not want to use a modalview as I want to maintain the top view on the screen. In the code below, I have it sort-of working, the top level slides up, but then completely disappears (fades) out.
Any help is greatly appreciated!
Thanks.
HomeOptionsViewController *homeOptionsViewController = [[HomeOptionsViewController alloc]
initWithNibName:#"HomeOptionsViewController"
bundle:nil];
// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];
UIView *newView = homeOptionsViewController.view;
//newView.frame = CGRectMake(0,300, 320,140);
newView.frame = CGRectMake(0,-10, 320,140);
// remove the current view and replace with myView1
//---[currentView removeFromSuperview];
[theWindow addSubview:newView];
theWindow.frame = CGRectMake(0,-110,320,200);
newView.frame = theWindow.bounds;
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromTop];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
//[theWindow setFrame:CGRectMake(0,200,320,300)];
[[theWindow layer] addAnimation:animation forKey:#"SwitchToView1"];
Any reason why you're not using standard UIView animations? CATransitions will entirely change the view because its supposed to be a transition from one view to the other.
Have you tried something like this? You add the view you want to slide just off the bottom of the screen, then animate both frames changing. It creates a slide up effect.
newView.frame = CGRectMake(0,416,320,140);
[theWindow addSubview:newView];
[UIView beginAnimations:#"SwitchToView1" context:nil];
[UIView setAnimationDuration:0.5];
theWindow.frame = CGRectOffset(theWindow.frame, 0, -140);
newView.frame = CGRectOffset(newView.frame, 0, -140);
[UIView commitAnimations];