UIView-图层方法
//
// ViewController.m
// UIView-图层概念
//
// Created by wangtouwang on 15/5/5.
// Copyright (c) 2015年 wangtouwang. All rights reserved.
// #import "ViewController.h" @interface ViewController () @property(nonatomic,strong) UIView *viewA;
@property(nonatomic,strong) UIView *viewB;
@property(nonatomic,strong) UIView *viewC; @end @implementation ViewController
@synthesize viewA;
@synthesize viewB;
@synthesize viewC; - (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor whiteColor]];
[self.navigationItem setTitle:@"图层概念"]; UIButton *addBtn1 = [[UIButton alloc] initWithFrame:CGRectMake(,, , )];
[addBtn1 setTitle:@"增加" forState:UIControlStateNormal];
addBtn1.titleLabel.font=[UIFont systemFontOfSize:13.0f];
[addBtn1 setBackgroundColor:[UIColor grayColor]];
[addBtn1 addTarget:self action:@selector(addDract) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addBtn1]; UIButton *addBtn2 = [[UIButton alloc] initWithFrame:CGRectMake(,, , )];
[addBtn2 setTitle:@"删除" forState:UIControlStateNormal];
addBtn2.titleLabel.font=[UIFont systemFontOfSize:13.0f];
[addBtn2 setBackgroundColor:[UIColor grayColor]];
[addBtn2 addTarget:self action:@selector(removeDract) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addBtn2]; UIButton *addBtn3 = [[UIButton alloc] initWithFrame:CGRectMake(,, , )];
[addBtn3 setTitle:@"叠加" forState:UIControlStateNormal];
addBtn3.titleLabel.font=[UIFont systemFontOfSize:13.0f];
[addBtn3 setBackgroundColor:[UIColor grayColor]];
[addBtn3 addTarget:self action:@selector(addSecquece) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addBtn3]; UIButton *addBtn4 = [[UIButton alloc] initWithFrame:CGRectMake(,, , )];
[addBtn4 setTitle:@"上移" forState:UIControlStateNormal];
addBtn4.titleLabel.font=[UIFont systemFontOfSize:13.0f];
[addBtn4 setBackgroundColor:[UIColor grayColor]];
[addBtn4 addTarget:self action:@selector(forUpMove) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addBtn4]; UIButton *addBtn5 = [[UIButton alloc] initWithFrame:CGRectMake(,, , )];
[addBtn5 setTitle:@"下移" forState:UIControlStateNormal];
addBtn5.titleLabel.font=[UIFont systemFontOfSize:13.0f];
[addBtn5 setBackgroundColor:[UIColor grayColor]];
[addBtn5 addTarget:self action:@selector(forDownMove) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addBtn5]; UIButton *addBtn6 = [[UIButton alloc] initWithFrame:CGRectMake(,, , )];
[addBtn6 setTitle:@"上下调换" forState:UIControlStateNormal];
addBtn6.titleLabel.font=[UIFont systemFontOfSize:13.0f];
[addBtn6 setBackgroundColor:[UIColor grayColor]];
[addBtn6 addTarget:self action:@selector(upForDown) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addBtn6];
} #pragma mark 增加图层
-(void)addDract{
viewA= [[UIView alloc] initWithFrame:CGRectMake(, , , )];
viewA.backgroundColor=[UIColor greenColor];
[self.view addSubview:viewA];
} #pragma mark 删除图层
-(void)removeDract{
[viewA removeFromSuperview];
} #pragma mark 图层叠加顺序 先添加的在下面 后添加的在上面
-(void)addSecquece{
viewB= [[UIView alloc] initWithFrame:CGRectMake(, , , )];
viewB.backgroundColor=[UIColor redColor];
[self.view addSubview:viewB]; viewC= [[UIView alloc] initWithFrame:CGRectMake(, , , )];
viewC.backgroundColor=[UIColor yellowColor];
[self.view addSubview:viewC];
} #pragma mark 图层向上移
-(void)forUpMove{
[self.view bringSubviewToFront:viewA];
} #pragma mark 图层向下移
-(void)forDownMove{
[self.view sendSubviewToBack:viewA]; } #pragma mark 上下调换
-(void)upForDown{
NSInteger indexC= [[self.view subviews] indexOfObject:viewC];
NSInteger indexA= [[self.view subviews] indexOfObject:viewA];
[self.view exchangeSubviewAtIndex:indexC withSubviewAtIndex:indexA];
} @end
UIView-图层方法的更多相关文章
- Mapcontrol 遍历所有图层方法
mapcontrol 遍历所有图层方法 2011-04-29 19:51 通过IMap中的get_layers()可以遍历MapControl中当前的图层.此方法可以通过指定UID对图层进行过滤或者分 ...
- 关于UIView的方法animateWithDuration:animations:completion:的说明
今天遇到一个问题,具体问题就不细说了,总之是UIView的动画导致的. 研究结果表明,UIViewController被挡住或没显示出来时,用UIView的静态方法animateWithDuratio ...
- UIView常见方法
- (void)addSubview:(UIView *)view; 添加一个子控件view - (void)removeFromSuperview; 从父控件中移除 - (UIView *)vi ...
- UIView回调方法(可以在添加子视图等,做一些额外操作)
didAddSubview didMoveToSuperview willMoveToSuperview didMoveToWindow willMoveToWindow willRemoveSubv ...
- iOS UIView控件的常用属性和方法的总结
一 UIVIew 常见属性1.frame 位置和尺寸(以父控件的左上角为原点(0,0))2.center 中点 (以父控件的左上角为原点(0,0))3.bounds 位置和尺寸(以自己的左上角为原点 ...
- iOS:UIView、UIControl、UIButton、UILabel简单的属性和方法常识
常见属性和方法 一 .UIVIew 常见属性 1.frame 位置和尺寸(以父控件的左上角为原点(0,0)) 2.center 中点 (以父控件的左上角为原点(0,0)) 3.bounds 位置和尺寸 ...
- iOS 中 UIView 和 CALayer 的关系
UIView 有一个名叫 layer ,类型为 CALayer 的对象属性,它们的行为很相似,主要区别在于:CALayer 继承自 NSObject ,不能够响应事件. 这是因为 UIView 除了负 ...
- 第一章 UI实战开发 UIWindow UIView
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- UIView详解
MVC架构模式 MVC(Model-View-Controller)是实现数据和显示数据的视图分离的架构模式(有一定规模的应用都应该实现数据和显示的分离).其中,M代表模型,就是程序中使用的数据和 ...
- iOS开发小技巧--实现毛玻璃效果的方法
一.美工出图 二.第三方框架 -- DRNRealTimeBlur,框架继承自UIView.使用方法:创建UIView直接继承自框架的View,就有了毛玻璃效果 三.CoreImage -- 图片加高 ...
随机推荐
- HDU3466-Proud Merchants(01背包变形)
需要排序的01背包. 这种题排序时只需要考虑两个怎么排,重载小于号就可以了. 需要注意的是,如果一个物品你想先放进背包里,那么你排序是要放到后面!01背包的放置顺序的倒着的! 看到别人的博客都只是比较 ...
- linux中vi/vim显示行号设置
vim打开文件是,默认不提示行号. 至于显示行号的用途,因人而异 临时修改只需要在编辑文件时输入 :set number 即可 linux下一个主机可能有N个账户.对于配置分为两种:仅配置当前账户,配 ...
- Struts一张图
- C# ip hash算法实现ip分流
private void button42_Click(object sender, EventArgs e) { Dictionary<int, string> proxyIpNodes ...
- Xcode6为什么干掉pch(Precompile Prefix Header)&如何添加pch文件
转载: http://blog.csdn.net/iosdevtip/article/details/40918353 一直在用xcode6开发,但项目都是在xcode5上创建的,所以一直没注意到, ...
- codeforces 132C Logo Turtle--- dp dfs
题目在这里:点击打开链接 题意: F表示前进一步,T表示变成反方向 给一串FT字符,和一个n,表示可以改变多少次,求可以走到的离原点最远的距离 改变就是F变成T.T变成F 关键: dfs(int d, ...
- 总结swift语言常见的20个问题和回答
1.假设我是个刚入门的iOS开发人员,选swift学习呢,还是选objective-c学习,还是两个都学? 这个能够依据两种情况来决定:1.我想进入公司担任iOS开发的职位 2.我仅仅想做个独立 ...
- JAVA Web 之 struts2文件上传下载演示(二)(转)
JAVA Web 之 struts2文件上传下载演示(二) 一.文件上传演示 详细查看本人的另一篇博客 http://titanseason.iteye.com/blog/1489397 二.文件下载 ...
- Java immutable class
可变类:类的实例创立之后,还可以修改这个实例的内容. 比如创建一个3*3的矩阵,如果设立了set function,在main中可以用set更改对应位置元素的大小. 不可变类:就是类的实例一旦被建立, ...
- 请列出你在从事IT生涯中,最难以忘怀的一次误操作
IT系统最怕什么,我觉得就两点: 1.不可靠的软硬件. 2.误操作. 第一点就不用解释了,第二点是该文的内容,主要摘选自ITPUB的精华贴——[精华] 请列出你在从事DBA生涯中,最难以忘怀的一次误操 ...