[英]Issues in UITabBar with SideMenu
我在目标c中以编程方式创建了标签栏控制器,我需要实现侧栏菜单。是否可以在标签栏控制器中实现侧栏菜单?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.tabBarController =[[UITabBarController alloc]init];
//Initialize View controller and speciality
UIViewController *viewcontroller1=[[HomeView alloc]init];
UIViewController *viewcontroller2=[[Speciality alloc]init];
UIViewController *viewcontroller3=[[Activity alloc]init];
UIViewController *viewcontroller4 =[[Notification alloc]init];
UIViewController *viewcontroller5 =[[Profile alloc]init];
self.tabBarController.viewControllers=[NSArray arrayWithObjects:viewcontroller1,viewcontroller2,viewcontroller3,viewcontroller4,viewcontroller5, nil];
self.window.rootViewController =self.tabBarController;
self.tabBarController.tabBar.barTintColor = [UIColor colorWithRed:0.376 green:0.729 blue:0.318 alpha:1.000];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
下载库https://github.com/John-Lluch/SWRevealViewController
并将文件SWRevealViewController.h
和SWRevealViewController.m
复制到您的项目中
在AppDelegate.h
#import "SWRevealViewController.h"
@property (strong,nonatomic) SWRevealViewController *revealViewController;
在AppDelegate.m
self.revealViewController = [[SWRevealViewController alloc]initWithRearViewController:leftViewController frontViewController:tabBarController];
if ( self.revealViewController )
{
UIButton *button1 = [[UIButton alloc]initWithFrame:CGRectMake(8, 65, 80, 30)];
[button1 setTitle:@"Side bar" forState:UIControlStateNormal];
[button1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[button1 addTarget:self.revealViewController action:@selector(revealToggle:) forControlEvents:UIControlEventTouchUpInside];
[tabBarController.view addSubview:button1];//if u hav navigation controller u can replace button1 with BarButtonItem
[tabBarController.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.