• iOS-自定义导航控制器


    BasicNavigationViewController:UINavigationViwController

    /*

      隐藏导航底部线条

    */

    -(void)viewDidLoad
    {
        [super viewDidLoad];
        self.interactivePopGestureRecognizer.enabled = YES;
        
        /**
         *  隐藏导航底部的线条
         */
        [self findHairlineFromView:self.navigationBar];
    }

    - (UIImageView *)findHairlineFromView:(UIView *)view
    {
        if ([view isKindOfClass:[UIImageView class]] && view.frame.size.height <= 1.0) {
            return (UIImageView *)view;
        }
        
        for (UIView *subView in view.subviews) {
            UIImageView *imageView = [self findHairlineFromView:subView];
            imageView.hidden= YES;
            if (imageView) {
                return imageView;
            }
        }
        
        return nil;
    }

    自定义导航控制器push下一个界面的时候的返回按钮

    -(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
    {
        if (self.viewControllers.count>0) {
            UIButton *backBtn=[DMWidget customButtonWithFrame:CGRectMake(0,0,22, 22) toView:nil];
            [backBtn setImage:[UIImage imageNamed:@"icon_返回"] forState:UIControlStateNormal];
            [backBtn setImage:[UIImage imageNamed:@"icon_返回"] forState:UIControlStateHighlighted];
            //[backBtn setTitle:@"返回" forState:UIControlStateNormal];
           // backBtn.titleLabel.font =[UIFont systemFontOfSize:DMFontSize15];
            //[backBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
            backBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 5);
            viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
        }
        [super pushViewController:viewController animated:animated];

    }

    #pragma mark - ---------------- 事件 ------------------
    #pragma mark - 返回
    - (void)backAction
    {
        [self popViewControllerAnimated:YES];
    }

  • 相关阅读:
    Oracle
    Oracle入门
    数据库测试的测试点
    overload重载与override重写的区别
    Java接口的default关键字用法解释
    pytest执行入口
    Gradle的安装与基本配置
    玩转HTML5+跨平台开发[5] HTML表单标签
    玩转HTML5+跨平台开发[4] HTML表格标签
    玩转HTML5+跨平台开发[3] HTML列表标签
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5411451.html
Copyright © 2020-2023  润新知