//
// ViewController.m
// UI1_UIView层操作
//
// Created by zhangxueming on 15/7/1.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
//self.view.backgroundColor=[UIColor cyanColor];
// Do any additional setup after loading the view, typically from a nib.
UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(10, 100, 320, 100)];
redView.backgroundColor = [UIColor redColor];
[self.view addSubview:redView]; UIView *greenView = [[UIView alloc] initWithFrame:CGRectMake(20, 140, 320, 100)];
greenView.backgroundColor = [UIColor greenColor];
[self.view addSubview:greenView]; UIView *yellowView = [[UIView alloc] initWithFrame:CGRectMake(30, 180, 320, 100)];
yellowView.backgroundColor = [UIColor yellowColor];
yellowView.alpha= 1.0;//值越大越不透明
[self.view addSubview:yellowView];
//先添加的视图在self.view的最底层, 后添加的视图在self.view的最顶层
//父视图 子视图
//获取父视图
UIView *superView = [redView superview];
superView.backgroundColor = [UIColor cyanColor];
[yellowView superview].backgroundColor = [UIColor whiteColor];
//获取子视图数组
NSArray *subViews = [self.view subviews];
((UIView *)[subViews objectAtIndex:0]).backgroundColor = [UIColor orangeColor];
NSLog(@"count = %li", subViews.count); //把子视图移到最顶层显示
[self.view bringSubviewToFront:redView];
//把子视图移动到最底层显示
[self.view sendSubviewToBack:redView]; UIView *insertView = [[UIView alloc] initWithFrame:CGRectMake(10, 160, 350, 100)];
insertView.backgroundColor = [UIColor blueColor];
//在指定下标位置增加视图
//[self.view insertSubview:insertView atIndex:1];
//在指定视图上层增加视图
//[self.view insertSubview:insertView aboveSubview:greenView];
//在指定视图下层增加视图
[self.view insertSubview:insertView belowSubview:greenView];
//交换两个位置的视图
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:3];
self.view.backgroundColor=[UIColor cyanColor];
//[self.view removeFromSuperview];
if([self.view superview])
{
NSLog(@"23");
}
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

UI1_UIView层操作的更多相关文章

  1. yii model层操作总结

    yii model层操作属性和方法总结. tableName – 设置Model所对应的表名,例如: public function tableName(){return 'gshop_order_e ...

  2. Linux2.6内核--对块IO层操作的讨论

          当一个块被调入内存时(也就是说,在读入后或等待写出时),它要存储在缓冲区中.每个缓冲区与一个块对应,它相当于是磁盘块在内存中的表示.块包含一个或多个扇区,但大小不能超过一页,所以一页可以容 ...

  3. JPA作持久层操作

    JPA(Hibernate是jpa的实现) jpa是对实体类操作,从而通过封装好的接口直接设置数据库的表结构.虽然jpa可以直接通过编写java代码来操作数据库表结构,避免了sql的编写,但别忘了需要 ...

  4. Hibernate深入浅出(九)持久层操作——数据保存&批量操作

      数据保存: 1)session.save session.save方法用于实体对象到数据库的持久化操作.也就是说,session.save方法调用与实体对象所匹配的Insert SQL,将数据插入 ...

  5. react 问题记录二(侧重于state或者说server层操作)

    项目体系说明:react+mobx+antd 11. state设置对象属性 this.setState({ tableParams:{tableName:value} }) 10.loading组件 ...

  6. linux下GPIO的用户层操作(sysfs)

    linux的GPIO通过sysfs为用户提供服务,下面是linux kernel里的说明文档,学习一下. GPIO Sysfs Interface for Userspace ============ ...

  7. JAVA实现DAO基本层CRUD操作

    随着shh2各种操作方便框架.越来越多JAVA WEB效率,可是,假设在不了解这些框架使用的场合的情况下,一拿到项目就盲目地选择这些框架进行系统架构的搭建,就有可能造成非常多不是必需的资源浪费. 在项 ...

  8. 八:SpringBoot-集成JPA持久层框架,简化数据库操作

    SpringBoot-集成JPA持久层框架,简化数据库操作 1.JPA框架简介 1.1 JPA与Hibernate的关系: 2.SpringBoot整合JPA Spring Data JPA概述: S ...

  9. ABP理论学习之N层架构

    返回总目录 自从写这个系列博客之后,发现很多园友还是希望有个直接运行的demo,其实在github上就有官方的demo,我直接把这demo的链接放到这里吧,另外,我分析,这些找不到demo的同学,很可 ...

随机推荐

  1. 【小白的java成长系列】——面向对象基础

    今天来说说java面向对象的知识点~事实上.java在其发展过程中可以成功.非常大一部分原因是其面向对象的思想~ 1.概念 如今来说面向对象思想.也不是什么新的知识点了,我们知道如今非常多语言都有面向 ...

  2. System.Data.SqlClient.SqlError: 备份集中的数据库备份与现有的 'XXX' 数据库不同

    System.Data.SqlClient.SqlError: 备份集中的数据库备份与现有的 'XXX' 数据库不同. 1. 删除与要恢复数据库同名的已经存在的数据库:2. 右击“数据库”选择“还原数 ...

  3. IDEA和Eclipse经常使用快捷键(Win Mac)

    一. 代码生成/补全 Alt+回车  导入包,自己主动修正(Eclipse中Ctrl+Shift+O ) Alt+Inser 生成getter setter.构造器 Ctrl+Shift+Space( ...

  4. 和iPhone有关的视图控制器:UIViewController、UITabBarController、UINavigationController及其混合用法

    iPhone中的view视图是应用程序对于数据最直观.最直接的呈现方式,如下是我在学习了iPhone中的视图控制器以及由其衍生的特殊子类的总结,希望对那些初学者有所帮助: UIViewControll ...

  5. ubuntu搭建LAMP服务器

    新手记录下...... 安装apache apt-get install apache2 安装mysql apt-get install mysql-server 安装php apt-get inst ...

  6. C# 网络通信大小端转换类

    本篇文章主要介绍了"C# 网络通信大小端转换类" using System;namespace Framework.NetPackage.Common { /// <summ ...

  7. 基于html5 canvas和js实现的水果忍者网页版

    今天爱编程小编给大家分享一款基于html5 canvas和js实现的水果忍者网页版. <水果忍者>是一款非常受喜欢的手机游戏,刚看到新闻说<水果忍者>四周年新版要上线了.网页版 ...

  8. Steps to Install Hadoop on CentOS/RHEL 6---reference

    http://tecadmin.net/steps-to-install-hadoop-on-centosrhel-6/# The Apache Hadoop software library is ...

  9. 使用 satis 搭建一个私有的 Composer 包仓库

    在我们的日常php开发中可能需要使用大量的composer包,大部份都可以直接使用,但在公司内部总有一小部份包是不能公开的,这时候我们就需要搭建一个公司内部使用的composer仓库,好在compos ...

  10. C# 自定义重绘DataGridView

    using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using Syste ...