博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
自定义导航栏--用法一
阅读量:5840 次
发布时间:2019-06-18

本文共 2370 字,大约阅读时间需要 7 分钟。

#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];

 

 

转载于:https://www.cnblogs.com/blogwithstudyofwyn/p/5384999.html

你可能感兴趣的文章
【ros】Create a ROS package:package dependencies报错
查看>>
通过容器编排和服务网格来改进Java微服务的可测性
查看>>
Java I/O操作
查看>>
灰度图像和彩色图像
查看>>
argparse - 命令行选项与参数解析(转)
查看>>
修改上一篇文章的node.js代码,支持默认页及支持中文
查看>>
java只能的round,ceil,floor方法的使用
查看>>
将txt文件转化为json进行操作
查看>>
我的2014-相对奢侈的生活
查看>>
Java设计模式
查看>>
华为OJ 名字美丽度
查看>>
mysql-This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME 错误解决
查看>>
基本概念复习
查看>>
红黑树
查看>>
【数据库】
查看>>
WindowManager.LayoutParams 详解
查看>>
安卓中数据库的搭建与使用
查看>>
AT3908 Two Integers
查看>>
.NET 设计规范--.NET约定、惯用法与模式-2.框架设计基础
查看>>
sql 内联,左联,右联,全联
查看>>