//

//  AppDelegate.m

//  UI01_UIView

//

//  Created by dllo on 15/7/29.

//  Copyright (c) 2015年 zhozhicheng. All rights reserved.

//

#import "AppDelegate.h"

@interface
AppDelegate ()

@property(nonatomic,retain)UIView *myView;

// 宏

#define WIDTH self.window.frame.size.width

#define HEIGHT self.window.frame.size.height

@end

@implementation AppDelegate

-(void)dealloc

{

[_myView
release];

[_window
release];

[superdealloc];

}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {

//创建一个和屏幕一般大的window

self.window = [[UIWindowalloc]
initWithFrame:[[UIScreenmainScreen]
bounds]];

// Override point for customization after application launch.

//给window一个背景颜色

self.window.backgroundColor = [UIColoryellowColor];

//让当前的window在应用程序中可见并显示出来

[self.windowmakeKeyAndVisible];

//对window进行释放

[_window
release];

//UIView

// 1.创建一个UIView的对象

UIView *view1=[[UIViewalloc]
initWithFrame:CGRectMake(100, 100, 100, 100)];

// 2.给view1设置背景颜色

view1.backgroundColor=[UIColorblueColor];

// 3.把视图贴到窗体上

[self.windowaddSubview:view1];

// 4.释放

[view1release];

//视图加入到父视图的数组之后,数组会添加视图的引用计数,对应的也就能够在加入之后对视图进行释放

UIView *view2=[[UIViewalloc]
initWithFrame:CGRectMake(130, 130, 100, 100)];

view2.backgroundColor=[UIColorwhiteColor];

[self.windowaddSubview:view2];

[view2release];

UIView *view3=[[UIViewalloc]
initWithFrame:CGRectMake(160, 160, 100, 100)];

view3.backgroundColor=[UIColorredColor];

[self.windowaddSubview:view3];

[view3release];

//视图的坐标起始位置在自己的父视图的左上角

NSLog(@"%g",WIDTH);

NSLog(@"%g",HEIGHT);

//一个视图能够有多个子视图,可是一个视图仅仅能有一个父视图

//
父视图

NSLog(@"%@",view2.superview);

//
子视图

NSLog(@"%@",self.window.subviews);

//先创建,先加入到subview的视图会在层级关系的最以下

//通过父视图来管理他身上全部子视图的层级关系

//父视图把指定的子视图放在最上面

[self.windowbringSubviewToFront:view2];

//父视图把指定的子视图放在最以下

[self.windowsendSubviewToBack:view2];

//用视图的frame属性,对视图位置大小进行又一次设置

view1.frame=CGRectMake(190, 190, 120, 120);

self.myView =[[UIViewalloc]
initWithFrame:CGRectMake(200, 200, 100, 100)];

self.myView.backgroundColor=[UIColorgrayColor];

[self.windowaddSubview:self.myView];

[_myView
release];

//
透明度

view3.alpha = 0.5;

// tag值

// tag设置不能为0,不能反复

view1.tag = 1000;

UIView *tempView = [self.windowviewWithTag:1000];

NSLog(@"%p",tempView);

NSLog(@"%p",view1);

return
YES;

}

- (void)applicationWillResignActive:(UIApplication *)application {

// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application
and it begins the transition to the background state.

// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

}

- (void)applicationDidEnterBackground:(UIApplication *)application {

// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

}

- (void)applicationWillEnterForeground:(UIApplication *)application {

// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

}

- (void)applicationDidBecomeActive:(UIApplication *)application {

// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

}

- (void)applicationWillTerminate:(UIApplication *)application {

// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}

@end


iOS UI01_UIView的更多相关文章

  1. iOS可视化动态绘制连通图

    上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...

  2. 【疯狂造轮子-iOS】JSON转Model系列之二

    [疯狂造轮子-iOS]JSON转Model系列之二 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇<[疯狂造轮子-iOS]JSON转Model系列之一> ...

  3. 【疯狂造轮子-iOS】JSON转Model系列之一

    [疯狂造轮子-iOS]JSON转Model系列之一 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 之前一直看别人的源码,虽然对自己提升比较大,但毕竟不是自己写的,很容易遗 ...

  4. iOS总结_UI层自我复习总结

    UI层复习笔记 在main文件中,UIApplicationMain函数一共做了三件事 根据第三个参数创建了一个应用程序对象 默认写nil,即创建的是UIApplication类型的对象,此对象看成是 ...

  5. iOS代码规范(OC和Swift)

    下面说下iOS的代码规范问题,如果大家觉得还不错,可以直接用到项目中,有不同意见 可以在下面讨论下. 相信很多人工作中最烦的就是代码不规范,命名不规范,曾经见过一个VC里有3个按钮被命名为button ...

  6. JS调用Android、Ios原生控件

    在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...

  7. 告别被拒,如何提升iOS审核通过率(上篇)

    iOS审核一直是每款移动产品上架苹果商店时面对的一座大山,每次提审都像是一次漫长而又悲壮的旅行,经常被苹果拒之门外,无比煎熬.那么问题来了,我们有没有什么办法准确把握苹果审核准则,从而提升审核的通过率 ...

  8. Swift3.0服务端开发(一) 完整示例概述及Perfect环境搭建与配置(服务端+iOS端)

    本篇博客算是一个开头,接下来会持续更新使用Swift3.0开发服务端相关的博客.当然,我们使用目前使用Swift开发服务端较为成熟的框架Perfect来实现.Perfect框架是加拿大一个创业团队开发 ...

  9. Summary of Critical and Exploitable iOS Vulnerabilities in 2016

    Summary of Critical and Exploitable iOS Vulnerabilities in 2016 Author:Min (Spark) Zheng, Cererdlong ...

随机推荐

  1. UI各种小控件的用法

    今天给大家列举出来UI中的一些小控件的用法.方便大的学习与使用 一些方法和属性我们能够查看API文档.不必将每一个控件的功能都记住, 由于在使用的过程中,我们能够查看API文档.方便使用,我们仅仅要记 ...

  2. Chrome插件开发新手教程

    近期在用百词斩这个站点来学单词,感觉非常不错,就是在回想单词列表的时候仅仅有单词和意思.却没有读音.感觉非常不方便,思来思去,想到了Chrome插件能够胜任这个工作.于是小小的研究了一下. Chrom ...

  3. Spyder调试快捷键

    Ctrl+1:  注释.取消注释 Ctrl+4/5:  块注释 / 取消块注释 F12: 断点 / 取消断点 F5: 运行 Ctrl+F5: 启动调试 Ctrl+F10: 单步调试,跳过函数内部实现 ...

  4. notepad++ 查找引用(Find Reference)(适用于c c++及各类脚本比如lua、python等)

    在程序开发过程中,程序员经常用到的一个功能就是查找引用(Find Reference),Visual Studio里面的对应功能是“查找所有引用”(Find All References). 我在使用 ...

  5. 在Ubuntu Server下搭建LAMP环境

    1 LAMP的安装 LAMP通常是指Linux+Apache+MySQL+PHP组合形成的一套可以运行PHP程序的体系,并不是一个软件的名称.没有安装MySQL的服务器依然可以在其它条件完备的情况下运 ...

  6. 解决:[WARNING] fpm_children_bury(), line 215: child 2736 (pool default) exited on signal 15 SIGTERM after 59.588363 seconds from start

    试用Nginx + PHP FastCGI 做WEB服务器,运行了几个月的时间,烦恼的是经常碰到Nginx 502 Bad Gateway 这个问题. 参考了很多修改办法,这个502的问题一直存在,今 ...

  7. ifame子页实现父页面刷新(或跳转到指定页面)

    <script>parent.location.replace('../D_DailyManager/Add.aspx?id=" + x + "');</scri ...

  8. JavaScript DOM编程艺术(第2版)学习笔记2(4~6章应用实例)

    本书的第4章使用第3章学到的操作DOM的方法和属性写了一个展示图片的网页,并在第5,6章对代码进行了优化. 第一版,搭建网页的静态结构,包括一级标题<h1>,无序列表清单<ul> ...

  9. 『转』Writing Well

    这是前辈Julie Zhuo的最新关于写作的文章,昨天写下-进行总结和阅读思考 这是一篇关于提笔写作的文章,首发在The looking glass...前辈每周都会回答一个读者的问题耶--This ...

  10. thinkphp5 模板中截取中文字符串

    TP5模板页截取中文字符串 {$vo.task_detail|mb_substr=###,0,15,'utf-8'}