UI UIView

//
//  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];
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值