# LYTabBar **Repository Path**: cityleaf/LYTabBar ## Basic Information - **Project Name**: LYTabBar - **Description**: 自定义tabbar,可调节中间按钮及上下偏移量 - **Primary Language**: Objective-C - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-07-14 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LYTabBar 针对中间带有自定义按钮的tabbar,可以自定义中间按钮,调节中间按钮大小,调节上下偏移量,耦合性低,可移植性强 使用方法,详细用法及效果请移步wiki中: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. /** * 第一步:定义各个视图 */ FirstViewController *firstVC = [[FirstViewController alloc]init]; firstVC.title = @"首页"; SecondViewController *secVC = [[SecondViewController alloc]init]; secVC.title = @"个人"; ThirdViewController *thirdVC = [[ThirdViewController alloc]init]; thirdVC.title = @"第三"; FourthViewController *fourthVC = [[FourthViewController alloc]init]; fourthVC.title = @"第四"; /** * 第二部:添加各个视图数组、item图片数组、item选中后的图片数组 */ LYTabbarController *tabbarController = [[LYTabbarController alloc]init]; [tabbarController addChildViewControllers:@[firstVC,secVC,thirdVC,fourthVC] images:@[@"home",@"home",@"person",@"person"] selectedImages:@[@"home_selected",@"home_selected",@"person_selected",@"person_selected"]]; /** * 第三部:设置中间按钮 不设置,默认尺寸(50,50),偏移量0.5居中显示 */ tabbarController.centerImage = [UIImage imageNamed:@"center"]; //设置按钮图片 tabbarController.centerSelectedImage = [UIImage imageNamed:@"center_selected"]; //设置按钮高亮图片 tabbarController.centerButtonOffset = 0.4; //设置按钮的上下偏移量 tabbarController.centerBounds = CGRectMake(0, 0, 60, 60); //设置按钮尺寸 tabbarController.centerButtonStyle = LYCenterButtonStyleBulge; //设置tabbar的背景图片中间是否带有凸起,有凸起和不凸起两种背景图片,默认不凸起 self.window.rootViewController = tabbarController; return YES; } 中间按钮的实现可以写在LYTabbarController的- (void)tabBar:(LYBar *)tabBar DidClickCenterButton:(UIButton *)centerButton方法里