1. 实现 UITableView可以 穿透状态栏 效果:
1. UITableView设置 占据屏幕,从 状态栏 下开始 布局
2. 设置内边距 状态栏 20(状态栏) +44(导航栏)+ nav(35) + 底部(tabbar 49)
设置底部内壁那局 底部(tabbar 49)避免内容被遮挡
2. 自定义 UITabBar 重写 layoutSubviews 重新摆放控件,把 + 摆放到中间即可
懒加载问题:
添加对应的View 到 scrollView
滚动到对应的View
3. nav 实现:
3.1. 添加 title ,添加 指示器, 设置指示器 centerX 等于 选中 按钮 centerX
3.2. XMGAllViewController *all = [[XMGAllViewController alloc] init];
[self addChildViewController:all];
添加 navController 到 self
3.3. [self.scrollView addSubview:childVc.view];
把 Controller 的 view 添加到 scrollView中
3.4. 监听滑动,修改 指示器坐标 、scrollView的 view 坐标
// 系统 api 触发 滚动时间,滚动停止触发
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
[self addChildVcView];
}
// 人为 手动滑动触发
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
}
核心代码
XMGTabBarController.m
#import "XMGTabBarController.h"
#import "OneController.h"
#import "TwoController.h"
#import "ThreeController.h"
#import "FourController.h"
#import "ModelController.h"
#import "XMGTabBar.h"
#import "XMGNavigationController.h"
@interface XMGTabBarController ()
@end
@implementation XMGTabBarController
- (void)viewDidLoad {
[super viewDidLoad];
// 第一个子控制器
OneController *oneVC= [[OneController alloc]init];
UINavigationController* oneVCN= [[UINavigationController alloc] initWithRootViewController:oneVC];
oneVCN.tabBarItem.title=@"A控制器";
//1. 分别设置
UIImage* image1= [UIImage imageNamed:@"navigationbar_friendsearch"];
UIImage* selelctImage1= [UIImage imageNamed:@"navigationbar_friendsearch_highlighted"];
// 系统会被默认图片渲染绿色,这里改变系统渲染图片的模式
selelctImage1= [selelctImage1
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
oneVCN.tabBarItem.image = image1;
oneVCN.tabBarItem.selectedImage = selelctImage1;
// tabbarItem 设置文字 属性
// 属性到 using the keys found in NSAttributedString.h 中找 UIKit下
//
[oneVCN.tabBarItem setBadgeValue:@"100"];
NSMutableDictionary* normalAttrs= [NSMutableDictionary dictionary];
normalAttrs[NSFontAttributeName]= [UIFont systemFontOfSize:14];
normalAttrs[NSForegroundColorAttributeName]=[UIColor blackColor];
// [oneVC.tabBarItem setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
NSMutableDictionary* selectAttrs= [NSMutableDictionary dictionary];
selectAttrs[NSForegroundColorAttributeName]=[UIColor redColor];
selectAttrs[NSFontAttributeName]= [UIFont systemFontOfSize:14];
// [oneVC.tabBarItem setTitleTextAttributes:selectAttrs forState:UIControlStateSelected];
//2. 统一设置
//setTitleTextAttributes:(nullable NSDictionary<NSAttributedStringKey,id> *)attributes forState:(UIControlState)state API_AVAILABLE(ios(5.0)) UI_APPEARANCE_SELECTOR;
// 后面 有 UI_APPEARANCE_SELECTOR 可以通过 appear设置
// 取出appear,统一设置,那么这个app中所有的 UITabBarItem 都有这个属性
UITabBarItem* item= [UITabBarItem appearance];
[item setTitleTextAttribut

最低0.47元/天 解锁文章
595

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



