UIview lianxi
// 创建一个和屏幕大小相同的window,记住[UIScreen mainScreen].bounds 是获取当前屏幕大小
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// 设置window的背景颜色
self.window.backgroundColor = [UIColor grayColor];
// 将window设置上,并让window显示
[self.window makeKeyAndVisible];
/*
// 打印屏幕大小,使用NSStringFromCGRect()
NSLog(@"%@", NSStringFromCGRect([UIScreen mainScreen].bounds));
// 添加一小块视图到屏幕上
// 1. 申请空间,并初始化大小
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
// 2. 设置view相关属性
view.backgroundColor = [UIColor whiteColor];
view.bounds = CGRectMake(20, 0, 200, 200);
// 3. 添加到window上
// 添加view到_window上,给_window发送消息
// 将一个view添加到window上时,view的引用计数会+1
[_window addSubview:view];
// 4. 发送一次release消息
[view release];
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 100, 100)];
view2.backgroundColor = [UIColor redColor];
[view addSubview:view2];
[view2 release];
// 使用中心点更改view的位置
// view.center = CGPointMake(320 / 2, 568 / 2);
// NSLog(@"%@", NSStringFromCGPoint(view.center));
// view2.center = CGPointMake(view.frame.size.width / 2, view.frame.size.height / 2);
// NSLog(@"%@", NSStringFromCGPoint(view2.center));
*/
//view1 蓝色
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 200, 200)];
view1.backgroundColor = [UIColor blueColor];
view1.tag = 1000;
[_window addSubview:view1];
[_window viewWithTag:1000].backgroundColor = [UIColor yellowColor];//根据tag值,取出view 设置
[view1 release];
//view2 红色
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(80, 20, 100, 400)];
view2.backgroundColor = [UIColor redColor];
view2.tag = 1001;
[_window addSubview:view2];
//[_window insertSubview:view2 belowSubview:view1];//将红 插到 蓝的底下
[view2 release];
//view3 紫色
UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(30, 30, 100, 100)];
view3.backgroundColor = [UIColor purpleColor];
view3.tag = 1002;
view3.hidden = NO;
view3.center = CGPointMake(160, 160);//设置中心点属性
[_window addSubview:view3];
//[_window insertSubview:view3 atIndex:1];
[view3 release];
// 将view提到最上层
//[_window bringSubviewToFront:view2];
// 将view放到最下层
// [_window sendSubviewToBack:view2];
// 将view2从父视图上移除
//[view2 removeFromSuperview];
NSLog(@"%@", view1.superview);
NSLog(@"%@", _window.subviews);
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 350, 200, 40)];
label.text = @"cai bi";
label.font = [UIFont fontWithName:@"Helvetica-Bold" size:40];
[_window addSubview:label];
[label release];
//
[_window viewWithTag:1000].alpha = 0.5;
UIview lianxi的更多相关文章
- UIView的layoutSubviews和drawRect方法何时调用
首先两个方法都是异步执行.layoutSubviews方便数据计算,drawRect方便视图重绘. layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSubvi ...
- iOS 自定义方法 - UIView扩展
示例代码 //#import <UIKit/UIKit.h>@interface UIView (LPCView)/** 上 */@property CGFloat top;/** 下 * ...
- UIView上的控件使用push方法跳转
有时候在项目中,为了保持前后页面的推进方式跳转方式一致,会在通过UIview上的控件跳到另一个Controller上,所以,这时候就需要用到这种方式了,当然,present方法可以实现跳转但是样式可能 ...
- IOS 杂笔-11(实现在外部无法改变UIView的size)
我想题目说的或许不是很清楚,那么现在我详细介绍一下这篇随笔内容. 在外部无法改变UIVIew控件的size. 这里说是UIView,但是事实上,是大多数控件而绝非仅UIView. 想要实现在外部无法改 ...
- iOS系列 基础篇 05 视图鼻祖 - UIView
iOS系列 基础篇 05 视图鼻祖 - UIView 目录: UIView“家族” 应用界面的构建层次 视图分类 最后 在Cocoa和Cocoa Touch框架中,“根”类时NSObject类.同样, ...
- 5. UIView
1. UIView 的初认识 官方文档 UIView class defines a rectangular area on the screen and the interfaces for man ...
- Swift - UIView,UItableView,Cell设置边框方法
// 设置边框的宽度 cell.layer.borderWidth = 1 // 设置边框的颜色 cell.layer.borderColor = UIColor.blackColor().CGCol ...
- iOS 使点击事件穿透透明的UIView
如图: 悬浮的三个按钮下方有一个可以点击的灰色区域,但是点击按钮之间的透明区域, 这三个按钮的contentView会响应这个点击事件,这时候需要让这个contentView不响应这个点击事件. 解决 ...
- iOS----自定义UIView,绘制一个UIView
绘制一个UIVIew最灵活的方式就是由它自己完成绘制.实际上你不是绘制一个UIView,你只是子类化了UIView并赋予子类绘制自己的能力.当一个UIVIew需要执行绘图操作的时,drawRect:方 ...
随机推荐
- 找出Active Directory架构操作主机方法!
- 来看看Github上流行的编码规范
Popular Coding Convention on Github是一个有趣的网站,它根据Github的代码提交情况分析了几种语言流行的代码规范,目前支持对JavaScript,Java,Py ...
- Python爬取CSDN博客文章
0 url :http://blog.csdn.net/youyou1543724847/article/details/52818339Redis一点基础的东西目录 1.基础底层数据结构 2.win ...
- gitlab 启动参考
第一步 启动gitlab bundle exec rails s -e production -d 第二步 启动redis /etc/init.d/redis start chkconfig redi ...
- SQLCLR
hsrzyn SQLCLR 什么是SQLCLR SQL CLR (SQL Common Language Runtime) 是自 SQL Server 2005 才出现的新功能,它将.NET Fr ...
- WPF converter
单值转换器 将单一值转换为特定类型的值,以日期转换为例如下: 1.定制DateConverter类,其中当值从绑定源传播给绑定目标时,调用方法Convert. 1 public class DateC ...
- springmvc xml 空模板
<?xml version="1.0" encoding="UTF-8"?><!-- Bean头部 --><beans xmlns ...
- 布局重用 include merge ViewStub
在布局优化中,Androi的官方提到了这三种布局<include />.<merge />.<ViewStub />,并介绍了这三种布局各有的优势,下面也是简单说一 ...
- Java使用poi对Execl简单_读和写_操作
1 /** 一.简单读取Execl的步骤: * 1.通过流来读取Execl并存放到内存中: * 2.通过WorkbookFactory工作簿工厂来读取内存中存放的execl文档流并创建出一个工作簿 * ...
- java 钱币的单位转换
将钱转成转换为带指定单位的钱 int money = 10; NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); System ...