首页 技术 正文
技术 2022年11月13日
0 收藏 712 点赞 3,407 浏览 3327 个字
//自定义标签工具栏
- (void) initTabBarView{
//
self.bottomView = [[UIView alloc]initWithFrame:CGRectMake(, kScreenHeight-tabViewHeight-,kScreenWidth, tabViewHeight+)];
[self.view addSubview:self.bottomView]; UIView *upLine = [[UIView alloc]initWithFrame:CGRectMake(, ,kScreenWidth, 0.5)];
upLine.backgroundColor = RGB(0xd4, 0xdd, 0xe3);
upLine.alpha = 0.16;
[self.bottomView addSubview:upLine]; UIView *downLine = [[UIView alloc]initWithFrame:CGRectMake(, 0.5 ,kScreenWidth, 0.5)];
downLine.backgroundColor = RGB(0x34, 0x53, 0x6a);
downLine.alpha = 0.16;
[self.bottomView addSubview:downLine]; _tabBarView = [[UIView alloc]initWithFrame:CGRectMake(, , kScreenWidth, tabViewHeight)];
_tabBarView.backgroundColor = [UIColor whiteColor]; [self.bottomView addSubview:_tabBarView]; NSArray *textArr = @[@"通讯录",@"常用联系人",@"个人中心"];
NSArray *imageNameArray = @[@"tab_ico_contact_nor.png",@"tab_ico_contact_hl.png",
@"tab_ico_collect_nor.png",@"tab_ico_collect_hl.png",
@"tab_ico_me_nor.png",@"tab_ico_me_hl.png"];
int tabCount =(int)textArr.count; NSMutableArray *spaceViews = [NSMutableArray arrayWithCapacity:tabCount+]; for (int i=; i < tabCount+; i++) {
UIView *v = [UIView new];
[spaceViews addObject:v];
[self.tabBarView addSubview:v]; [v mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(tabViewHeight);
make.centerY.mas_equalTo(self.tabBarView.mas_centerY);
}];
}
[spaceViews[] mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.tabBarView.mas_left); }];
for(int i= ;i< textArr.count;i++)
{
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.tag = +i;
[btn setImage:[UIImage imageNamedWithoutCache:imageNameArray[i*] ] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamedWithoutCache:imageNameArray[i*+] ] forState:UIControlStateSelected];
[btn setImage:[UIImage imageNamedWithoutCache:imageNameArray[i*+] ] forState:UIControlStateHighlighted];
[btn setTitle:textArr[i] forState:UIControlStateNormal];
[btn setTitleColor:RGB(0x7c, 0x86, 0x8d) forState:UIControlStateNormal];
[btn setTitleColor:RGB(, 0x9c, 0xff) forState:UIControlStateHighlighted];
[btn setTitleColor:RGB(, 0x9c, 0xff) forState:UIControlStateSelected];
btn.titleLabel.font = [UIFont systemFontOfSize: /];
[btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
btn.frame = CGRectMake(kScreenWidth/tabCount*i + kScreenWidth/(tabCount*), (tabViewHeight-btnHeight)/,kScreenWidth/(*tabCount) , btnHeight); //kScreenWidth/(2*tabCount) btn.bounds.size.width
btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[btn setTitleEdgeInsets:UIEdgeInsetsMake(btn.imageView.image.size.height, -btn.imageView.image.size.width, , )];
[btn setImageEdgeInsets:UIEdgeInsetsMake(, ,btn.titleLabel.bounds.size.height, -btn.titleLabel.bounds.size.width)]; [self.tabBarView addSubview:btn]; [spaceViews[i+] mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(btn.mas_right);
make.width.equalTo(((UIView *)spaceViews[i]).mas_width);
}]; [btn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.tabBarView.mas_top).offset((tabViewHeight-btnHeight)/);
make.bottom.equalTo(self.tabBarView.mas_bottom).offset(-(tabViewHeight-btnHeight)/);
make.height.equalTo(@);
make.left.equalTo(((UIView *)spaceViews[i]).mas_right);
make.right.equalTo(((UIView *)spaceViews[i+]).mas_left);
}];
if(i == )
{
[btn setSelected:YES];
} } [spaceViews[tabCount] mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.tabBarView.mas_right);
}];}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905