初学 -UI_1


#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// 产生一个window对象, 使它和屏幕大小一样。
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
//改变背景颜色
self.window.backgroundColor = [UIColor yellowColor];
//把window对象 设置为主 window,并且可见
[self.window makeKeyAndVisible];

//1.建立一个UIView对象
//UIView通过CGRect结构体 确定 位置和大小
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 150, 200)];
//2.对view进行设置
view.frame = CGRectMake(200, 200, 100, 100);// frame 属性
[view setBackgroundColor:[UIColor redColor]];// 背景颜色

view.center = CGPointMake(0, 0);// 设置中心点坐标

//视图的属性设置

// 透明度 0为完全透明
view.alpha = 0.1;

// 隐藏/显示
view.hidden = NO; //YES 为隐藏 NO 为显示

view.tag = 10000; //设置view的tag值(作用:方便父类视图快速定位子视图)


//3. 将view对象 添加到window 上
[self.window addSubview:view];

NSLog(@"%@", view.superview);//获取view的父类视图

//通过tag寻找子视图

UIView *viewTemp = [self.window viewWithTag:1000];

NSLog(@"%@, %@", view, viewTemp);



//4.内存管理
[view release];

UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(80, 100, 220, 200)];
[view1 setBackgroundColor:[UIColor blackColor]];
[self.window addSubview:view1];
[view1 release];


UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(100, 180, 200, 280)];
[view2 setBackgroundColor:[UIColor orangeColor]];
[self.window addSubview:view2];
[view2 release];

UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(30, 80, 150, 160)];
[view3 setBackgroundColor:[UIColor greenColor]];
[view2 addSubview:view3];
[view3 release];

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




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值