点击tabbarItem变Item的背景色

来源:互联网 发布:夏普网络扫描仪工具 编辑:程序博客网 时间:2024/06/10 00:41

1、创建一个Veiw 把View插入到tabbarViewcontroller insetViewatIndex:0]
2、设置tabbar的delegate方法:- (void)tabBarController:(UITabBarController )tabBarController didSelectViewController:(UIViewController )viewController里设置uiview的frame为屏幕宽度/4 * 49,`- (void)tabBarController:(UITabBarController )tabBarController didSelectViewController:(UIViewController )viewController
{
NSInteger index = tabBarController.selectedIndex;
selectView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/4 * index, 0, [UIScreen mainScreen].bounds.size.width/4, 49);

}`就可以实现这种效果这里写图片描述

3、当需要直接跳转到某一个tabbar时点击效果会有异常只需这样写就可以完美解决[self.tabBarController setSelectedIndex:0];
[self.tabBarController.delegate tabBarController:self.tabBarController didSelectViewController:self];

0 0
原创粉丝点击