I am having trouble in showing infobutton to navigate to information page/view.
I have written this code.
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
toolBar.items = [NSArray arrayWithObjects:infoButtonItem, nil];
I got infolight button but i do not now know how to do animate & navigation action method in to flip to info page.
I also want infobutton to stay at center, currently it is at left corner.
This will create ur info button in center.
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
[infoButton addTarget:self action:#selector(goToRechercherView) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *flexibleLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
toolbar.items = [NSArray arrayWithObjects:flexibleLeft,infoButtonItem,flexibleLeft, nil];
This is for swipe animation. add your view inside.
-(void)goToRechercherView{
[UIView beginAnimations:#"flipview" context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.view cache:YES];
[UIView commitAnimations];
}
There are two ways to do this...
First one is......
newView setFrame:CGRectMake( 0.0f, 480.0f, 320.0f, 480.0f)]; //notice this is OFF screen!
[UIView beginAnimations:#"animateView" context:nil];
[UIView setAnimationDuration:0.4];
[newView setFrame:CGRectMake( 0.0f, 0.0f, 320.0f, 480.0f)]; //notice this is ON screen!
[UIView commitAnimations];
Second option is to use built in animations as flip and curl:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:newView
cache:YES];
[self.navigationController.view addSubview:settingsView.view];
[UIView commitAnimations];
Related
I have created a button programmatically and added a selector to it
(touched) which when touchup inside should transist to the next view
controller (LocationVC) with no navigationController between. I have
added in storyboard a second view controller and named its class
"LocationVC2. Somehow nothing happens then a black screen. Any help?
//
// ViewController.h
// NanCom4
//
// Created by Daniel Habshush on 8/30/15.
// Copyright © 2015 Daniel Habshush. All rights reserved.
//
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
#property (nonatomic, strong) IBOutlet UIButton *circle1;
#property (nonatomic, strong) IBOutlet UIButton *circle2;
#property (nonatomic, strong) IBOutlet UIButton *circle3;
#property (nonatomic, strong) IBOutlet UIButton *circle4;
#property (nonatomic, strong) IBOutlet UIButton *circle5;
#end
- (void)viewDidLoad {
[super viewDidLoad];
circle1 = [[UIButton alloc] init];
[circle1 setFrame:CGRectMake(128, 247, 100, 100)];
[circle1 setIsAccessibilityElement:YES];
[circle1 addTarget:self action:#selector(pressed3:) forControlEvents:UIControlEventTouchUpInside];
circle1.backgroundColor = [UIColor clearColor];
[circle1 setImage:[UIImage imageNamed:#"Circle6.png"] forState:UIControlStateNormal];
[self.view addSubview:circle1];
circle2 = [[UIButton alloc] init];
[circle2 setFrame:CGRectMake(55, 170, 120, 120)];
[circle2 setIsAccessibilityElement:YES];
[circle2 addTarget:self action:#selector(touch:) forControlEvents:UIControlEventTouchUpInside];
circle2.backgroundColor = [UIColor clearColor];
[circle2 setTitle:#"Orit" forState:UIControlStateNormal];
[circle2 setBackgroundImage: [UIImage imageNamed:#"pie2.png"] forState:UIControlStateNormal];
[self.view addSubview:circle2];
circle3 = [[UIButton alloc] init];
[circle3 setFrame:CGRectMake(55, 300, 120, 120)];
[circle3 setIsAccessibilityElement:YES];
[circle3 setAlpha:0];
circle3.backgroundColor = [UIColor clearColor];
[circle3 setTitle:#"DANI" forState:UIControlStateNormal];
[circle3 setBackgroundImage: [UIImage imageNamed:#"pie3.png"] forState:UIControlStateNormal];
[self.view addSubview:circle3];
circle4 = [[UIButton alloc] init];
[circle4 setFrame:CGRectMake(185, 300, 120, 120)];
[circle4 setIsAccessibilityElement:YES];
[circle4 setAlpha:0];
circle4.backgroundColor = [UIColor clearColor];
[circle4 setTitle:#"DANI" forState:UIControlStateNormal];
[circle4 setBackgroundImage: [UIImage imageNamed:#"pie5.png"] forState:UIControlStateNormal];
[self.view addSubview:circle4];
circle5 = [[UIButton alloc] init];
[circle5 setFrame:CGRectMake(185, 170, 120, 120)];
[circle5 setIsAccessibilityElement:YES];
[circle5 setAlpha:0];
circle5.backgroundColor = [UIColor clearColor];
[circle5 setTitle:#"DANI" forState:UIControlStateNormal];
[circle5 setBackgroundImage: [UIImage imageNamed:#"pie4.png"] forState:UIControlStateNormal];
[self.view addSubview:circle5];
}
- (void)pressed3:(UIButton*)sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.circle1.alpha = 0.2;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.circle2.alpha = 1;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelay:0.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.circle3.alpha = 1;
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelay:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.circle4.alpha = 1;
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelay:0.75];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.circle5.alpha = 1;
[UIView commitAnimations];
}
- (void)touch:(id)sender
{
LocationVC *newVC = [LocationVC new];
[self presentViewController:newVC animated:YES completion:nil];
}
#end
Hi all
I have attached below code. Upon launch, the view controller displays
a logo in the center and four main user buttons on the bottom.I try to
achieve that if the first button got touched up inside (Called Lists),
the logo fades and the center circle displays the name (Lists) of the
first button and shows around it buttons with different submenu
points, in the same time the 4 main (initial) buttons fade and are
only seen at a minimal (low Alpha). I want to achieve that if the
faded (half visible)main button gets touched again initial view is
restored with logo and only the main four menu buttons. Meaning, first
touch shows sub menus and its animations and second click returns to
initial view. Again clicked shows again submenu and so on. How can i
do that?
Thanks Dnai
//
// ViewController.h
// NanCom1
//
// Created by Daniel Habshush on 8/13/15.
// Copyright © 2015 Daniel Habshush. All rights reserved.
//
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
#property (nonatomic, retain) IBOutlet UIImageView* logo;
#property (nonatomic, retain) IBOutlet UIButton* button1;
#property (nonatomic, retain) IBOutlet UIButton* button2;
#property (nonatomic, retain) IBOutlet UIButton* button3;
#property (nonatomic, retain) IBOutlet UIButton* button4;
#property (nonatomic, retain) IBOutlet UIButton* listMain;
#property (nonatomic, retain) IBOutlet UIButton* shoppingList;
#property (nonatomic, retain) IBOutlet UIButton* todoList;
#end
//
// ViewController.m
// NanCom1
//
// Created by Daniel Habshush on 8/13/15.
// Copyright © 2015 Daniel Habshush. All rights reserved.
//
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
{
UIDynamicAnimator* _animator;
UIGravityBehavior* _gravity;
UICollisionBehavior* _collision;
}
#synthesize logo, button1, button2, button3, button4, listMain, todoList, shoppingList;
- (void)viewDidLoad {
[super viewDidLoad];
logo = [[UIImageView alloc] init];
UIImage *logoPic = [UIImage imageNamed:#"Logo3.png"];
logo.image=logoPic;
logo.frame = CGRectMake(100, 200, 175, 175);
[logo setAlpha:0];
[self.view addSubview:logo];
[UIImageView beginAnimations:nil context:nil];
[UIImageView setAnimationDuration:3.0];
[UIImageView setAnimationDelay:0.5];
[UIImageView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.logo.alpha = 1.0;
[UIImageView commitAnimations];
button1 = [[UIButton alloc] init];
[button1 setFrame:CGRectMake(5, 2, 90, 90)];
[button1 setIsAccessibilityElement:YES];
button1.backgroundColor = [UIColor clearColor];
[button1 setBackgroundImage:[UIImage imageNamed:#"Circle.png"] forState:UIControlStateNormal];
[button1 setTitle:#"Lists" forState:UIControlStateNormal];
[button1.titleLabel setFont:[UIFont fontWithName:#"Avenir" size:13]];
[button1 addTarget:self action:#selector(pressed:) forControlEvents:UIControlEventTouchUpInside];
[button1 setEnabled:YES];
[self.view addSubview:button1];
button2 = [[UIButton alloc] init];
[button2 setFrame:CGRectMake(85, 2, 90, 90)];
[button2 setIsAccessibilityElement:YES];
button2.backgroundColor = [UIColor clearColor];
[button2 setBackgroundImage:[UIImage imageNamed:#"Circle.png"] forState:UIControlStateNormal];
[button2 setTitle:#"Cirlce" forState:UIControlStateNormal];
[button2.titleLabel setFont:[UIFont fontWithName:#"Avenir" size:13]];
[button2 setEnabled:YES];
[button2 addTarget:self action:#selector(pressed2:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button2];
button3 = [[UIButton alloc] init];
[button3 setFrame:CGRectMake(160, 2, 90, 90)];
button3.backgroundColor = [UIColor clearColor];
[button3 setBackgroundImage:[UIImage imageNamed:#"Circle.png"] forState:UIControlStateNormal];
[button3 setTitle:#"Location" forState:UIControlStateNormal];
[button3.titleLabel setFont:[UIFont fontWithName:#"Avenir" size:13]];
[button3 setEnabled:YES];
[button2 addTarget:self action:#selector(pressed3:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button3];
button4 = [[UIButton alloc] init];
[button4 setFrame:CGRectMake(250, 2, 90, 90)];
button4.backgroundColor = [UIColor clearColor];
[button4 setTitle:#"Menu" forState:UIControlStateNormal];
[button4.titleLabel setFont:[UIFont fontWithName:#"Avenir" size:13]];
[button4 setBackgroundImage:[UIImage imageNamed:#"Circle.png"] forState:UIControlStateNormal];
[button4 setEnabled:YES];
[button2 addTarget:self action:#selector(pressed4:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button4];
_animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
_gravity = [[UIGravityBehavior alloc] initWithItems:#[button1, button2, button3, button4]];
[_animator addBehavior:_gravity];
_collision = [[UICollisionBehavior alloc]
initWithItems:#[button1, button2, button3, button4]];
_collision.translatesReferenceBoundsIntoBoundary = YES;
[_animator addBehavior:_collision];
UIDynamicItemBehavior* itemBehaviour4 = [[UIDynamicItemBehavior alloc] initWithItems:#[button4]];
itemBehaviour4.elasticity = 0.4;
itemBehaviour4.resistance = 0.65;
[_animator addBehavior:itemBehaviour4];
UIDynamicItemBehavior* itemBehaviour3 = [[UIDynamicItemBehavior alloc] initWithItems:#[button3]];
itemBehaviour3.elasticity = 0.45;
itemBehaviour3.resistance = 0.5;
[_animator addBehavior:itemBehaviour3];
UIDynamicItemBehavior* itemBehaviour2 = [[UIDynamicItemBehavior alloc] initWithItems:#[button2]];
itemBehaviour2.elasticity = 0.5;
itemBehaviour2.resistance = 0.3;
[_animator addBehavior:itemBehaviour2];
UIDynamicItemBehavior* itemBehaviour1 = [[UIDynamicItemBehavior alloc] initWithItems:#[button1]];
itemBehaviour1.elasticity = 0.37;
itemBehaviour1.resistance = 0.2;
[_animator addBehavior:itemBehaviour1];
}
- (void)pressed:(UIButton*)button1 {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.button1.alpha = 0.3;
self.button2.alpha = 0.3;
self.button3.alpha = 0.3;
self.button4.alpha = 0.3;
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.logo.alpha = 0;
[UIView commitAnimations];
listMain = [[UIButton alloc] init];
[listMain setFrame:CGRectMake(100, 200, 175, 175)];
listMain.backgroundColor = [UIColor clearColor];
[listMain setBackgroundImage:[UIImage imageNamed:#"Circle.png"] forState:UIControlStateNormal];
[listMain setTitle:#"Lists" forState:UIControlStateNormal];
[listMain.titleLabel setFont:[UIFont fontWithName:#"Avenir" size:35]];
[listMain setAlpha:0];
[self.view addSubview:listMain];
todoList = [[UIButton alloc] init];
[todoList setFrame:CGRectMake(60, 145, 75, 75)];
todoList.backgroundColor = [UIColor clearColor];
[todoList setBackgroundImage:[UIImage imageNamed:#"Circle.png"] forState:UIControlStateNormal];
[todoList setTitle:#"ToDo" forState:UIControlStateNormal];
[todoList.titleLabel setFont:[UIFont fontWithName:#"Avenir" size:13]];
[todoList setAlpha:0];
[self.view addSubview:todoList];
shoppingList = [[UIButton alloc] init];
[shoppingList setFrame:CGRectMake(10, 245, 75, 75)];
shoppingList.backgroundColor = [UIColor clearColor];
[shoppingList setBackgroundImage:[UIImage imageNamed:#"Circle.png"] forState:UIControlStateNormal];
[shoppingList setTitle:#"Shopping" forState:UIControlStateNormal];
[shoppingList.titleLabel setFont:[UIFont fontWithName:#"Avenir" size:13]];
[shoppingList setAlpha:0];
[self.view addSubview:shoppingList];
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.listMain.alpha = 1;
self.todoList.alpha = 1;
self.shoppingList.alpha = 1;
[UIView commitAnimations];
}
- (void)pressed2:(UIButton*)button2 {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.button2.alpha = 1;
self.button1.alpha = 1;
self.button3.alpha = 1;
self.button4.alpha = 1;
self.listMain.alpha = 0;
self.todoList.alpha = 0;
self.shoppingList.alpha = 0;
[UIView commitAnimations];
}
- (void)pressed3:(UIButton*)button3 {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.listMain.alpha = 0;
self.todoList.alpha = 0;
self.shoppingList.alpha = 0;
self.logo.alpha = 1;
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.button2.alpha = 1;
self.button1.alpha = 1;
self.button3.alpha = 1;
self.button4.alpha = 1;
[UIView commitAnimations];
}
- (void)pressed4:(UIButton*)button4 {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.button2.alpha = 1;
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.button1.alpha = 1;
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.button3.alpha = 1;
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn ];
self.button4.alpha = 1;
[UIView commitAnimations];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
I am trying to make a slide out notification bar for when the app receives a notification and the app is currently open and in the foreground. I got this working with a custom UIView (actually it's a UIButton) and an animation. For some reason though it won't register a press when I tap on it. It won't call the selector method. Code is below:
-(void)appOpenPush {
//get string
NSLog(#"got a push while app was open");
AppDelegate *appDelegate =(AppDelegate *)[[UIApplication sharedApplication] delegate];
NSString *pushString = appDelegate.pushString;
//play sound
AudioServicesPlaySystemSound(MessageSound);
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
//note I am actually using a button here
UIButton *pushView =[[UIButton alloc] initWithFrame:CGRectMake(0, -75, [[UIScreen mainScreen] bounds].size.width,75)];
pushView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.8];
[pushView addTarget:self action:#selector(pushSlidePress) forControlEvents:UIControlEventTouchUpInside];
//set image
UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"icon120.png"]];
logo.frame=CGRectMake(5, 20, 35, 35);
logo.layer.cornerRadius=8;
logo.clipsToBounds=YES;
[pushView addSubview:logo];
UILabel *pushLabel = [[UILabel alloc] initWithFrame:CGRectMake(48, 34, 0, 0)];
pushLabel.text=pushString;
pushLabel.font=[UIFont systemFontOfSize:13];
[pushLabel sizeToFit];
pushLabel.textColor=[UIColor whiteColor];
[pushView addSubview:pushLabel];
//animate
UIWindow* currentWindow = [UIApplication sharedApplication].keyWindow;
[currentWindow addSubview:pushView];
[UIView animateWithDuration:0.4 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
pushView.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width,75);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.4 delay:2.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
pushView.frame = CGRectMake(0, -75, [[UIScreen mainScreen] bounds].size.width,75);
} completion:^(BOOL finished) {
[pushView removeFromSuperview];
}];
}];
}
Could anyone give me a pointer to why this isn't working? Is it because I am adding the UIButton to the main window? Any tips would be really helpful. thanks!
You have to add UIViewAnimationOptionAllowUserInteraction as an option to both of your animation blocks.
As per the documentation :
"Allow the user to interact with views while they are being animated."
Try this to avoid logo and pushLabel receive touches events:
logo.userInteractionEnabled = NO;
pushLabel.userInteractionEnabled = NO;
So it turns out you can't simply detect a press if the button is moving. I tested this by just adding the frame setup without it animating and it registered the press, when animation is turned on it doesn't. Seems that UIButton doesn't have tracking built in. I did come up with a quick fix. I just made a button the same size as the total animation area (i.e. the size of my slide out bar) and added that to the currentWindow on top of the animation frame. So it's just a clear invisible button on top of the animation but it's not moving itself. i.e:
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0,[[UIScreen mainScreen]bounds].size.width , 75)];
[button addTarget:self action:#selector(pushSlidePress) forControlEvents:UIControlEventTouchUpInside];
[currentWindow addSubview:button];
[UIView animateWithDuration:0.4 delay:0.0 options:(UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction) animations:^{
pushView.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width,75);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.4 delay:2.0 options:(UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction) animations:^{
pushView.frame = CGRectMake(0, -75, [[UIScreen mainScreen] bounds].size.width,75);
} completion:^(BOOL finished) {
[pushView removeFromSuperview];
[button removeFromSuperview];
}];
}];
Obviously you are covering an area of the screen that might block other things being pressed, but it depends on your setup. The animation is quick and I only have one button that the notification bar will block and it's too quick to notice. Hopefully this will be helpful to someone else trying to achieve a similar thing. Thanks for your help guys.
I need to change an image of a UIButton ,where the user hit the button, it will be flipped, and change to a new image ,this one does not flips ,but only change the image .
CABasicAnimation *crossFade = [CABasicAnimation animationWithKeyPath:#"transform.rotation.y"];
crossFade.duration = 1.0;
crossFade.fromValue = (id)cell.imageView.image.CGImage;
crossFade.toValue = (id)Cellimg.CGImage;
crossFade.removedOnCompletion = NO;
crossFade.fillMode = kCAFillModeForwards;
[cell.imageView.layer addAnimation:crossFade forKey:#"rotationY"];
[cell setImage:Cellimg forState:UIControlStateNormal];
What am I doing wrong?
Why don't you create a custom button with an image view? Something like this-
UIImage *img = [UIImage imageNamed:#"path/to-image.png"];
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.imageView.transform = CGAffineTransformMakeRotation(M_PI); // flip the image view
[button setImage:img forState:UIControlStateNormal]
Solved it with this :
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.50f];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:cell cache:NO];
// [baseBtn setTitle:newTitle forState:UIControlStateNormal];
[cell setImage:Cellimg forState:UIControlStateNormal];
[UIView commitAnimations];
I have taken a empty application,initially login screen is shown.On entering valid credentials user is navigated to home page where TabBar is shown.On tapping settings icon tab bar should move half way aside.But with my code settings screen is underneath tab bar.How to do so that TabBar also moves.I dont want to use any 3rd part controls.Looking for help.Thanks in advance.Below is my code:
-(void)login{
UIViewController *viewController1 = [[FirstViewController alloc] init];
UINavigationController * firstNavigation = [[UINavigationController alloc]initWithRootViewController:viewController1];
UIViewController *viewController2 = [[SecondViewController alloc] init];
UINavigationController * secondNavigation = [[UINavigationController alloc]initWithRootViewController:viewController2];
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = #[firstNavigation ,secondNavigation ];
[self.navigationController pushViewController:tabBarController animated:NO];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
_isSideMenuOpen = NO;
UIButton *imageButton1a = [UIButton buttonWithType:UIButtonTypeCustom];
imageButton1a.frame = CGRectMake(0,0,30,30);
[imageButton1a setImage:[UIImage imageNamed:#"setting_icon.png"] forState:UIControlStateNormal];
[imageButton1a addTarget:self action:#selector(goToSettings) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barItem1 = [[UIBarButtonItem alloc] initWithCustomView:imageButton1a];
self.navigationItem.leftBarButtonItem = barItem1;
lbl=[[UILabel alloc]initWithFrame:CGRectMake(10, 100, 150, 30)];
[self.view addSubview:lbl];
lbl.text=#"test label to move";
myView = [[UIView alloc] initWithFrame:self.view.frame];
myView.backgroundColor = [UIColor brownColor];
[myView setFrame:CGRectMake(0, 60, -160, 480)];
[self.view addSubview:myView];
}
-(void)goToSettings
{
if (_isSideMenuOpen)
{
_isSideMenuOpen = NO;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:self];
[myView setFrame:CGRectMake(0, 60, -160, 480)];
[UIView commitAnimations];
// self.view.frame=CGRectMake(0,0,320,self.view.frame.size.height);
}
else
{
_isSideMenuOpen = YES;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[myView setFrame:CGRectMake(0, 60, 160, 480)];
[UIView commitAnimations];
// self.view.frame=CGRectMake(160,0,320,self.view.frame.size.height);
}
}
below is screen shot of o/p I got
but expected o/p is UITabBar should move