zoukankan      html  css  js  c++  java
  • 自定义导航栏--用法一

    #pragma mark------------------------
    #pragma mark------------------------自定义导航
        self.title=@"外卖";
        
        UITapGestureRecognizer *tapLeft = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(changeCity)];
        UIView *leftItemView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, iPhoneWidth/7, 30)];
        [leftItemView addGestureRecognizer:tapLeft];
        leftItemView.backgroundColor = [UIColor redColor];
        UIButton *locationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        locationBtn.frame = CGRectMake(30, 0, 30, 30);
        [locationBtn setImage:[UIImage imageNamed:@"pulldownIcon"] forState:UIControlStateNormal];
        [locationBtn addTarget:self action:@selector(changeCity) forControlEvents:UIControlEventTouchUpInside];
        [leftItemView addSubview:locationBtn];
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftItemView];
        
        
        UILabel *cityNameLab=[UILabel new];//[[UILabel alloc]initWithFrame:CGRectMake(0,10, 80, 50)];
        [leftItemView addSubview:cityNameLab];
        cityNameLab.font=[UIFont systemFontOfSize:14];//51px
        cityNameLab.text=@"杭州";
        cityNameLab.textAlignment=NSTextAlignmentRight;
        //WEAKSELF(ws);
        [cityNameLab makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(locationBtn.mas_left).with.offset(0);
            make.centerY.equalTo(locationBtn.mas_centerY);
            make.width.equalTo(@60);
            make.height.equalTo(@40);
        }];
        
        
        
    
    #pragma mark--------------------------------------------------------------------
        UITapGestureRecognizer *tapRight = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(gotoSearchVC)];
        UIView *rightItemView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, iPhoneWidth/7, 30)];
        [rightItemView addGestureRecognizer:tapRight];
        rightItemView.backgroundColor = [UIColor redColor];
        UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        searchBtn.frame = CGRectMake(30, 0, 30, 30);
        [searchBtn setImage:[UIImage imageNamed:@"search_icon"] forState:UIControlStateNormal];
        [searchBtn addTarget:self action:@selector(gotoSearchVC) forControlEvents:UIControlEventTouchUpInside];
        [rightItemView addSubview:searchBtn];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightItemView];

     

  • 相关阅读:
    使用history.back()出现"警告: 网页已过期的解决办法"
    thinkphp5 如何将带分隔符的字符串转换成索引数组,并且遍历到前台
    MYSQL查询某字段中以逗号分隔的字符串的方法
    SpringBoot项目docker化
    全选Js
    【同步工具类】CountDownLatch
    Elasticsearch 2.3.2 安装部署
    从网络获取多张二维码图片,压缩打包下载
    传统的线程互斥技术:Synchronized关键字
    定时器的编写
  • 原文地址:https://www.cnblogs.com/blogwithstudyofwyn/p/5384999.html
Copyright © 2011-2022 走看看