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 -- 图片加高 ...
随机推荐
- HDU5407.CRB and Candies(数论)
官方题解: The problem is just to calculate g(N) = LCM(C(N,0),C(N,1),...,C(N,N)) Introducing function f(n ...
- Worker、Task、Executor三者之间的关系
- A Tour of Go Forever
If you omit the loop condition it loops forever, so an infinite loop is compactly(简洁地:紧密地:细密地) expre ...
- hdoj 1241 Oil Deposits
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- linux下查看本机socket端口详细信息
netstat -paut [root@OA-JRY-SY-FDEP1 nginx-]# netstat -paut Active Internet connections (servers and ...
- oc学习笔记2
.oc中的BOOL类型 oc中的BOOL类型的值为YES和NO,有点小奇怪 在oc中YES不等于1,但是NO一定等于0,所以不要把1和YES来比较 .消息发送 在oc中,经常使用这样的术语:将allo ...
- 普通SQL注入
安全防御:过滤/转义非法参数,屏蔽SQL查询错误. 工具:Firefox,hackbar,sqlmap,burpsuite 1.联想tms站 例1, 联想tms站fromCity参数存在普通SQL注入 ...
- How to create a PPPoE Server on Ubuntu? (Untested)
How to create a PPPoE Server on Ubuntu? March 30, 2011 coder_commenter Leave a comment Go to comment ...
- 采用jsp用表格的形式显示
<%@page import="cn.hncu.domain.*"%><%@ page language="java" import=&quo ...
- linux如何查进程、杀进程
本文系转载,转载原文地址:http://blog.sina.com.cn/s/blog_637112040100vl53.html 1.查进程 ps命令查找与进程相关的PID号: ps a 显 ...