-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
UITabBar *tab = self.view.subviews[1];
tab.layer.borderColor = [UIColor whiteColor].CGColor;
UIView *wapperView = tab.subviews[0];
wapperView.frame = CGRectMake(0,2, CGRectGetWidth(self.view.frame),48);
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame)/4,2)];
_slideView = v;
v.backgroundColor = kGlobalColor;
[tab addSubview:v];
for (UIView *v in tab.subviews) {
if ([v isMemberOfClass:[UIImageView class]]) {
//memberofclass是判断实例是否是给到的类实例化而来的对象,iskindofclass 是判断当前类是否是给到的类或者是它的子类实例化而来的
[v removeFromSuperview];
break;
}
}
}
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
[UIView animateWithDuration:.35 animations:^{
_slideView.frame = CGRectMake(CGRectGetWidth(_slideView.frame) *self.selectedIndex, CGRectGetMinY(_slideView.frame), CGRectGetWidth(_slideView.frame), CGRectGetHeight(_slideView.frame));
}];
}
{
__weak UIView *_slideView;
}
本文介绍如何通过Swift代码自定义UITabBar的样式,包括设置背景颜色、边框颜色等,并实现一个滑动指示器随选项卡变化的动画效果。
684

被折叠的 条评论
为什么被折叠?



