iOS-系统tabbar加选中条

来源:互联网 发布:java json post请求 编辑:程序博客网 时间:2024/05/21 06:34

-(void)viewDidAppear:(BOOL)animated{

    

    [superviewDidAppear:animated];

    

    UITabBar *tab =self.view.subviews[1];

    tab.layer.borderColor = [UIColorwhiteColor].CGColor;

   UIView *wapperView = tab.subviews[0];

    wapperView.frame =CGRectMake(0,2,CGRectGetWidth(self.view.frame),48);

    

    UIView *v = [[UIViewalloc] initWithFrame:CGRectMake(0,0, CGRectGetWidth(self.view.frame)/4,2)];

    _slideView = v;

    v.backgroundColor =kGlobalColor;

    [tabaddSubview:v];

    

   for (UIView *vin tab.subviews) {

        

       if ([v isMemberOfClass:[UIImageViewclass]]) {

//memberofclass是判断实例是否是给到的类实例化而来的对象,iskindofclass 是判断当前类是否是给到的类或者是它的子类实例化而来的

            [v removeFromSuperview];

           break;

        }

    }

}



-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{

    

    [UIViewanimateWithDuration:.35animations:^{

        

        _slideView.frame =CGRectMake(CGRectGetWidth(_slideView.frame) *self.selectedIndex,CGRectGetMinY(_slideView.frame),CGRectGetWidth(_slideView.frame),CGRectGetHeight(_slideView.frame));

        

    }];

    

}


{

   __weak UIView *_slideView;

}



0 0
原创粉丝点击