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 -- 图片加高 ...
随机推荐
- HW2.6
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- Go语言简介
Go语言简介 - Go语言是由Google开发的一个开源项目,目的之一为了提高开发人员的编程效率. Go语言简介 Go语言是由Google开发的一个开源项目,目的之一为了提高开发人员的编程效率. Go ...
- oc学习之路----代理模式2-使用步骤
之前已经写过一个个人关于代理模式的一些看法,现在就来总结一下使用代理模式的步骤吧. 1.先搞清楚谁是谁的代理(delegate) ● 2.定义代理协议,协议名称的命名规范:控件类名 + Delegat ...
- java初学的几个问题
1. 请问配置JDK时环境变量path和JAVA_HOME的作用是什么? 作用:告诉操作系统编译器运行的路径和生成的类路径.这样java源程序才可以进行编译和运行. 以下4-7题请在JDK环境下编译和 ...
- android 数据库的升级与降级解决方案
在我们写的程序中不避免的需要升级.或者说需要改变业务逻辑,那这个时候就需要修改数据库的字段,来适应不同的表结构 我们一般写数据库都是操作一个继承至 SQLiteOpenHelper 的类 然后我们需要 ...
- ip头、tcp头、udp头详解及定义,结合Wireshark抓包看实际情况
公司的同事们在分析网页加载慢的问题,忽然使用到了Wireshark工具,我就像发现新大陆一样好奇,赶紧看了看,顺便复习了一下相关协议.上学时学的忘的差不多了,汗颜啊! 报文封装整体结构 mac帧头定义 ...
- 更改cmd语言(chcp)
chcp 437 更改为英文 chcp 936 更改为简体中文 mode con cp select=437 mode con cp /status chcp cmd /c "chcp 43 ...
- JAVA自动生成正则表达式工具类
经过很久的努力,终于完成了JAVA自动生成正则表达式工具类.还记得之前需要正则,老是从网上找吗?找了想修改也不会修改.现在不用再为此烦恼了,使用此生成类轻松搞定所有正则表达式.赶快在同事面前炫一下吧. ...
- java中synchronized使用方法
synchronized的一个简单样例 public class TextThread { /** * @param args */ public static void main(String[ ...
- [Webpack 2] Expose modules to dependencies with Webpack
When you have a dependency that has dependencies on global variables (like jQuery or lodash) or assu ...