返回上一视图,凸显一个视图,其他视图变模糊
//
// AchievementViewController.m
// LIBAOZHENG0826
//
// Created by 张艳锋 on 15/8/27.
// Copyright (c) 2015年 张艳锋. All rights reserved.
//
#import "AchievementViewController.h"
#import "LBZModelDataAll.h"
#import "LBZPrefixHeader.pch"
@interface AchievementViewController ()
{
__weak IBOutlet UIScrollView *ZYFachievementscrollView;
UIView *PoetIntroduceview;
UIView *bgview;
}
- (IBAction)ZYFdoBackButton:(id)sender;
@end
@implementation AchievementViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor brownColor];//设置背景色
[self button];//调用button方法
}
- (IBAction)ZYFdoBackButton:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];//返回上一页面
}
-(void)button{
NSArray *arrbutton=[LBZModelDataAll dataArrayFromModel:poet_list];//从宏定义中抽取数据
NSLog(@"%lu",(unsigned long)arrbutton.count);
for (int i=0; i<arrbutton.count; i++) {
NSLog(@"%@",[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:i andNSString:poet_id]);
//自动生成button
UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(110*(i%5)+30,150*(int)(i/5), 80, 138)];
button.tag=i;//添加tag值方便点击时知道点击的是哪一个
UIImageView *figurephoto=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 80, 138)];
figurephoto.image=[UIImage imageNamed:@"card_back_new1.png"];//在按钮上面添加图片不会影响按钮的使用,
[button addSubview:figurephoto];
//诗人名字标签(初始化规格,获取数据,设置标签字体大小位置)
UILabel *poetnameLable=[[UILabel alloc]initWithFrame:CGRectMake(0, 115, 80, 8)];
poetnameLable.text=[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:i andNSString:name_poet_list];
poetnameLable.font=[UIFont systemFontOfSize:12];
poetnameLable.textAlignment=NSTextAlignmentCenter;
[button addSubview:poetnameLable];
UILabel *figureLable=[[UILabel alloc]initWithFrame:CGRectMake(20, 128, 60, 10)];
//设置标签文字
figureLable.text=[NSString stringWithFormat:@"0/%@",[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:i andNSString:poet_id]];
figureLable.font=[UIFont systemFontOfSize:12];
figureLable.textAlignment=NSTextAlignmentCenter;
[button addSubview:figureLable];
[ZYFachievementscrollView addSubview:button];
ZYFachievementscrollView.contentSize=CGSizeMake(568, 150*(int)(i/5)+150);//有效显示区域,这样设置可以根据按钮的多少自动调节视图的高度也就是一长串按钮的长度,
[button addTarget:self action:@selector(showPoetIntroduce:) forControlEvents:UIControlEventTouchUpInside];
}
}
-(void)showPoetIntroduce:(UIButton *)sender{
NSLog(@"人物小传");
int a=(int)sender.tag;//tag值不是整形数据,但是可以进行强转换
// self.view.alpha=0.4;//有问题(上面的view同明度也变化)设置透明度的时候,这个视图上的所有物件都跟着变化透明度改变的是设置物件上面的所有,默认将物件上所有打包成为一个整体
//新视图
PoetIntroduceview=[[UIView alloc]initWithFrame:CGRectMake(30, 50, 520, 220)];
//添加背景
PoetIntroduceview.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"poet_extra_info_bg.png"]];
//左边
UIView *leftView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 220)];
UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(18, 50, 140, 120)];
imageview.image=[UIImage imageNamed:@"people_0001.png"];
[leftView addSubview:imageview];
UILabel *aLable=[[UILabel alloc]initWithFrame:CGRectMake(160, 40, 160, 20)];
aLable.text=[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:a andNSString:name_poet_list];
aLable.font=[UIFont systemFontOfSize:15];
aLable.textAlignment=NSTextAlignmentCenter;
[leftView addSubview:aLable];
UILabel *bLable=[[UILabel alloc]initWithFrame:CGRectMake(160, 60, 160, 20)];
bLable.text=[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:a andNSString:birth2death];
bLable.font=[UIFont systemFontOfSize:10];
bLable.textAlignment=NSTextAlignmentCenter;
[leftView addSubview:bLable];
UILabel *cLable=[[UILabel alloc]initWithFrame:CGRectMake(160, 80, 20, 15)];
cLable.text=@"字:";
cLable.textColor=[UIColor redColor];
cLable.font=[UIFont systemFontOfSize:12];
cLable.textAlignment=NSTextAlignmentLeft;
[leftView addSubview:cLable];
UILabel *c1Lable=[[UILabel alloc]initWithFrame:CGRectMake(180, 80, 140, 15)];
c1Lable.text=[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:a andNSString:extra];
c1Lable.font=[UIFont systemFontOfSize:12];
c1Lable.textAlignment=NSTextAlignmentLeft;
[leftView addSubview:c1Lable];
UILabel *dLable=[[UILabel alloc]initWithFrame:CGRectMake(160, 95, 20, 15)];
dLable.text=@"号:";
dLable.textColor=[UIColor redColor];
dLable.font=[UIFont systemFontOfSize:12];
dLable.textAlignment=NSTextAlignmentLeft;
[leftView addSubview:dLable];
UILabel *d1Lable=[[UILabel alloc]initWithFrame:CGRectMake(180, 95, 140, 15)];
d1Lable.text=[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:a andNSString:call];
d1Lable.font=[UIFont systemFontOfSize:12];
d1Lable.textAlignment=NSTextAlignmentLeft;
[leftView addSubview:d1Lable];
UILabel *eLable=[[UILabel alloc]initWithFrame:CGRectMake(160, 110, 30, 15)];
eLable.text=@"世称:";
eLable.textColor=[UIColor redColor];
eLable.font=[UIFont systemFontOfSize:12];
eLable.textAlignment=NSTextAlignmentLeft;
[leftView addSubview:eLable];
UILabel *e1Lable=[[UILabel alloc]initWithFrame:CGRectMake(190, 110, 130, 15)];
e1Lable.text=[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:a andNSString:nickname];
e1Lable.font=[UIFont systemFontOfSize:12];
e1Lable.textAlignment=NSTextAlignmentLeft;
[leftView addSubview:e1Lable];
UILabel *fLable=[[UILabel alloc]initWithFrame:CGRectMake(160, 125, 160, 15)];
fLable.text=@"世称来历:";
fLable.textColor=[UIColor redColor];
[leftView addSubview:fLable];
fLable.font=[UIFont systemFontOfSize:12];
fLable.textAlignment=NSTextAlignmentLeft;
UITextView *f1textview=[[UITextView alloc]initWithFrame:CGRectMake(160, 140, 160,60)];
f1textview.backgroundColor=[UIColor colorWithRed:1 green:1 blue:1 alpha:0];
f1textview.text=[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:a andNSString:nick_desc];
f1textview.font=[UIFont systemFontOfSize:12];
f1textview.textAlignment=NSTextAlignmentLeft;
[leftView addSubview:f1textview];
//右边
UIView *rightView=[[UIView alloc]initWithFrame:CGRectMake(340, 0, 180, 220)];
UILabel *gLable=[[UILabel alloc]initWithFrame:CGRectMake(20, 20, 70, 20)];
gLable.backgroundColor=[UIColor colorWithRed:0.7 green:0.1 blue:0.1 alpha:1.0];
gLable.text=@"人物小传";
[rightView addSubview:gLable];
UITextView *textView=[[UITextView alloc]initWithFrame:CGRectMake(20, 40, 150, 170)];
textView.text= [LBZModelDataAll dataDetailFromModel:poet_list andDataNum:a andNSString:xiao_zhuan];
textView.backgroundColor=[UIColor colorWithRed:1 green:1 blue:1 alpha:0];
textView.font=[UIFont systemFontOfSize:12];
textView.textAlignment=NSTextAlignmentLeft;
[rightView addSubview:textView];
//表层视图
[PoetIntroduceview addSubview:leftView];
[PoetIntroduceview addSubview:rightView];
//下层遮挡视图通过添加一层中间视图并调节透明度使所需要显现的视图后面视图变暗,而所需要显现的视图继续明亮
//bgview和PoetIntroduceview是并列的,bgview用于遮挡后面视图,所以大小跟整体屏幕一样大,颜色可以为黑色或各种颜色,根据所喜好,透明度设为0.6或0.7可以若隐若现,增强美感。而PoetIntroduceview默认的透明度是跟self.view一样的因为它是添加到self.view上的。此时就凸现出来了
bgview=[[UIView alloc]initWithFrame:self.view.frame];
bgview.backgroundColor=[UIColor blackColor];
bgview.alpha=0.6;
[self.view addSubview:bgview];
[self.view addSubview:PoetIntroduceview];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
//点击移除诗人介绍和遮挡层
[PoetIntroduceview removeFromSuperview];
[bgview removeFromSuperview];
}
@end
转载于:https://www.cnblogs.com/OIMM/p/4773473.html
返回上一视图,凸显一个视图,其他视图变模糊相关推荐
- 【译】如何使用索引视图和一个只有2行的表限制业务规则
假设一个业务规则规定某些情况不允许存在.并且不允许使用外键进行限制,此时Instead of 触发器可以作为备选答案,但是通常这类触发器在以后带来的麻烦会多于其带来的便利.还有一种解决方式是使用包含唯 ...
- 安卓学习之路之如何显示一个listview列表视图
1.新建个安卓项目,点击res下的values目录,在该目录下创建一个名字为arrays.xml的Android xml文件,然后开始在里面写代码,代码如下: <?xml version=&qu ...
- Shiro的subject实质上是当前执行用户的特定视图。
Shiro的subject实质上是当前执行用户的特定视图. 通过org.apache.shiro.SecurityUtils可以查询当前执行用户: Subject currentUser = Secu ...
- Vue data 中随意更改一个属性,视图都会被更新吗?
以下内容来自公众号逆锋起笔,关注每日干货及时送达 作者:Rudy24 链接:https://juejin.cn/post/7040733315791323143 面试官:看过 Vue 的源码没? 候选 ...
- selenium如何在同一个窗口页面中返回上一个页面窗口(Python)。
用driver.back() 方法,(当前窗口返回上一级页面) 上代码: 用一个简单的网页做实验.百度新闻,它的标签页都是本页面加载. url = http://news.baidu.com/ fro ...
- android布局翻译,android – 使用翻译动画将视图从一个布局转换为另一个布局
我是 Android动画的新手,我的要求是在点击该视图时将视图从一个布局转换为单个xml文件中的布局. 场景: 假设我单击一个按钮,它出现在xml文件中标题的顶部,它应该向下移动/转换(它应该会产生一 ...
- linux 返回上一个文件夹_常用命令之linux指令
无论是在服务器上进行开发,还是在 android 上执行一些指令,都需要用到 linux 的一些命令行操作,所以,必须要学习一些 linux 指令的基本操作. 下面是我整理的一些 linux 基本操作 ...
- android切换到上个页面,Android 返回上一个界面刷新数据
有些界面需要返回上一个界面刷刷新数据,再此做个记录. 首先startActivityForResult进行Actvity进行跳转,这是跳转前的界面. // 通过 startActivityForRes ...
- postman参数化--上一个接口返回的数据作为下一个接口的参数
postman是测试接口经常使用的工具,它是一个很强大的工具.那么在测试中若是存在接口依赖的现象改怎么测试呢? 在使用postman做接口测试的时候,在多个接口的测试中,如果需要上一个接口的返回值作为 ...
- 安卓HTML中打开一个连接!点击跳转了,可以实现返回上一级的HTML的页面!
安卓HTML中打开一个连接!点击跳转了,可以实现返回上一级的HTML的页面! 一般都要监听手机的返回按钮和页面上的返回按钮 //监听手机的返回按钮 @Override public boolean o ...
最新文章
- Google服务器 IP
- HttpClient在传参和返回结果的中文乱码问题
- 中文文本纠错 算例实现(有算例完整代码)
- MyBatis 特殊字符处理
- javascript学习系列(19):数组中的Array.from方法
- python输入一个假分数_腾讯内容开放平台
- 用c++实现简单单链表,双链表,二叉树类
- java高级多线程编程--关于线程的停止问题
- mysql数据排序问题
- 100UF50V 10*8.4贴片电解电容封装尺寸
- CSR烧录工具csr单个蓝牙烧录小工具qcc300x烧录软件/CSR86xx烧写工具
- 类似123321特殊数的输出
- UPCOJ-5344 - 被子 - 瞎搞
- C语言中的getchar函数与putchar函数
- iOS 防键盘遮挡
- java apache 日志_了解Apache的访问日志
- 刚刚开通,感受一下此地气氛
- Mac 截图工具 iShot Pro - 软件介绍、下载安装详细教程
- 家庭玩游戏配置哪种计算机,玩游戏用什么系统?Win10专业版和Win10家庭版玩游戏的区别...
- 套料排版代码python_钣金制造管理系统Fabcost自动套料排版设置
热门文章
- 手把手教你强化学习 (九) 强化学习中策略梯度算法
- 经典机器学习系列(七)【聚类分析】
- vue.js把mounted里面的变量传到data里面
- 设计模式12——代理模式
- Xcode10升级问题:Multiple commands produce Info.plist
- Ugly Numbers UVA - 136
- 4.1 软件开发生命周期模型
- 【Python】if __name__ == __main__做了什么?
- javascript;json数据,js转换日期方法。
- windows 服务的安装与卸载之bat脚本命令