导航栏穿透效果原理图

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
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值