//
// 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-图层方法的更多相关文章

  1. Mapcontrol 遍历所有图层方法

    mapcontrol 遍历所有图层方法 2011-04-29 19:51 通过IMap中的get_layers()可以遍历MapControl中当前的图层.此方法可以通过指定UID对图层进行过滤或者分 ...

  2. 关于UIView的方法animateWithDuration:animations:completion:的说明

    今天遇到一个问题,具体问题就不细说了,总之是UIView的动画导致的. 研究结果表明,UIViewController被挡住或没显示出来时,用UIView的静态方法animateWithDuratio ...

  3. UIView常见方法

    - (void)addSubview:(UIView *)view; 添加一个子控件view   - (void)removeFromSuperview; 从父控件中移除 - (UIView *)vi ...

  4. UIView回调方法(可以在添加子视图等,做一些额外操作)

    didAddSubview didMoveToSuperview willMoveToSuperview didMoveToWindow willMoveToWindow willRemoveSubv ...

  5. iOS UIView控件的常用属性和方法的总结

    一 UIVIew 常见属性1.frame 位置和尺寸(以父控件的左上角为原点(0,0))2.center 中点 (以父控件的左上角为原点(0,0))3.bounds 位置和尺寸(以自己的左上角为原点 ...

  6. iOS:UIView、UIControl、UIButton、UILabel简单的属性和方法常识

    常见属性和方法 一 .UIVIew 常见属性 1.frame 位置和尺寸(以父控件的左上角为原点(0,0)) 2.center 中点 (以父控件的左上角为原点(0,0)) 3.bounds 位置和尺寸 ...

  7. iOS 中 UIView 和 CALayer 的关系

    UIView 有一个名叫 layer ,类型为 CALayer 的对象属性,它们的行为很相似,主要区别在于:CALayer 继承自 NSObject ,不能够响应事件. 这是因为 UIView 除了负 ...

  8. 第一章 UI实战开发 UIWindow UIView

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...

  9. UIView详解

    MVC架构模式   MVC(Model-View-Controller)是实现数据和显示数据的视图分离的架构模式(有一定规模的应用都应该实现数据和显示的分离).其中,M代表模型,就是程序中使用的数据和 ...

  10. iOS开发小技巧--实现毛玻璃效果的方法

    一.美工出图 二.第三方框架 -- DRNRealTimeBlur,框架继承自UIView.使用方法:创建UIView直接继承自框架的View,就有了毛玻璃效果 三.CoreImage -- 图片加高 ...

随机推荐

  1. POJ3254Corn Fields(状压DP)

    题意: John 有一个豪华的M*N个格子组成的新牧场 他想种美味的玉米 但是有些位置不能种 而且他种地不选择相邻的格子 求所有可能的种地方法 (不种也算一种选择)输入:第一行M和N, 第二行M*N地 ...

  2. 教程-Delphi设置功能表

    1.锁定窗体上的控件,禁止移动位置 D7-Edit>Lock Controls 2.设置控件永久显示名字 D7-Tools>Environment Options>Designer& ...

  3. 关键在封装并发出了帧-IP冲突也无所谓

    最近有点走火入魔了!本文所用技术非标准,较真儿者慎入!! 一个局域网内,两台机器拥有同样的IP,可以吗? 这不就是IP地址冲突吗?当然不行! 可是要知道,如果搞点旁门左道,还是可以做到的! 首先要明白 ...

  4. Modules you should know in Python Libray

    前两天被问到常用的python lib和module有哪些?最常用的那几个,其他的一下子竟然回答不上.想想也是,一般情况下,遇到一个问题,在网上一搜,顺着线索找到可用的例子,然后基本没有怎么深究.结果 ...

  5. HDU 4635 - Strongly connected(2013MUTC4-1004)(强连通分量)

    t这道题在我们队属于我的范畴,最终因为最后一个环节想错了,也没搞出来 题解是这么说的: 最终添加完边的图,肯定可以分成两个部X和Y,其中只有X到Y的边没有Y到X的边,那么要使得边数尽可能的多,则X部肯 ...

  6. 配置ModSecurity防火墙与OWASP规则

    中文译文参考:http://netsecurity.51cto.com/art/201407/446264.htm 英文原文参考:http://resources.infosecinstitute.c ...

  7. jQuery的DOM操作小案例

    案例一:下拉列表左右选择 <body> <div> <select style="width:60px" multiple size="10 ...

  8. C# 读取 timestamp 时间戳 值为byte[] 类型时转换为时间戳字符串

    C# 中如何读取出来的时间戳为 byte[] 类型的话,用以下方式转换成 16进制字符串 string tmpUfts = "0x"+ BitConverter.ToString( ...

  9. cocos2d-x学习笔记

    转自:http://blog.csdn.net/we000636/article/details/8263503 接受触屏事件的优先级是值越小,响应触屏事件的优先级越高 Z值越大,越外面 JNI:允许 ...

  10. 大型网站都喜欢把js写在html中的真正原因

    相信经常观察大站的朋友都会发现,他们都把CSS写在HTML页面里,一个页面的或者多个页面的背景图片,都集成到一张图片里,他们有的JS文件,也写到页面里了……也许你会迷惑,现在到处讲页面的优化,不都是要 ...