说明 |
时间 |
首次发布 |
2017年01月09日 |
最近更新 |
2019年11月28日 |
- (void)firstMethod {
static NSInteger index = 0;
UITabBarItem *item = self.navigationController.tabBarItem;
if (index % 2 == 1) {
item.title = @"首页";
item.image = [UIImage imageNamed:@"home"];
item.selectedImage = [UIImage imageNamed:@"home_selected"];
} else {
item.title = @"历史";
item.image = [UIImage imageNamed:@"history"];
item.selectedImage = [UIImage imageNamed:@"history_selected"];
}
index++;
NSLog(@"%ld", index);
}
- (void)secondMethod {
static NSInteger index = 0;
NSArray<UITabBarItem *> *items = self.tabBarController.tabBar.items;
if (index % 2 == 1) {
items.firstObject.title = @"首页";
items.firstObject.image = [UIImage imageNamed:@"home"];
} else {
items.firstObject.title = @"历史";
items.firstObject.image = [UIImage imageNamed:@"history"];
}
}