//
// VisionAppDelegate.m
// UIView
//
// Copyright (c) 2014年 Vision. All rights reserved.
//
#import "VisionAppDelegate.h"
@implementation VisionAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//创建一个UIWindows的对象 跟屏幕一样大
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
//设置背景颜色
self.window.backgroundColor = [UIColor colorWithRed:0.9 green:0.1 blue:0.4 alpha:1];
//设置这个window为主windows,并使其可见
[self.window makeKeyAndVisible];
//UIView的使用
//学习一个新类
//1.看继承关系
//2.有没有自己的初始化方法
//frame是UIView的一个属性,作用:规定view的位置和大小
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(150, 150, 55, 55)];
//把view添加到另一个view(UIWindow)上
view.backgroundColor = [UIColor colorWithRed:0.1 green:0.9 blue:0.6 alpha:1];
[self.window addSubview:view];//对view引用计数加1
//内存管理
[view release];
UIView *otherView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 88)];
otherView.backgroundColor = [UIColor greenColor];
[self.window addSubview:otherView];
[otherView release];
//将一个View放到最前面
[self.window bringSubviewToFront:view];
//将一个view放到后面
[self.window sendSubviewToBack:view];
//将某个view从父视图移除
[view removeFromSuperview];//调用该方法 会使得自己引用计数-1 如果 view上还有view 一并移除掉
//view的相关设置
//透明度 (0 - 1float)带着所有子视图透明度一起改变
otherView.alpha = 0.3;
//隐藏(YES隐藏 / NO显示)
otherView.hidden = YES;
//获得自己的父视图
NSLog(@"view的父视图:%@",
otherView.superview);
//获得一个view的子视图
NSLog(@"view的子视图:%@",
otherView.subviews);
//tag值
//给view加一个编号,方便父视图查找某个子视图
otherView.tag = 10000;
//父视图找子视图的方法
UIView *searchView = [self.window viewWithTag:10000];
NSLog(@"%@,",searchView);
//透明的颜色是clearColor
//内存管理
[_window release];
return YES;
}
- (void)dealloc
{
[_window release];
[super dealloc];
}
UI UIView
最新推荐文章于 2023-04-06 13:12:05 发布