AppDelegate.m
- (void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
// //面包 = 小麦 + 糖 == UIView = CALayer + 事件
//
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
// //设置圆角
// view.layer.cornerRadius = 10;
view.clipsToBounds = YES;
view.layer.masksToBounds = YES;
// //设置阴影
// view.layer.shadowColor = [UIColor blackColor].CGColor;
// //设置阴影大小
// view.layer.shadowOffset = CGSizeMake(10, 0);
// view.backgroundColor = [UIColor redColor];
// view.layer.shadowOpacity = 1;
//
// //设置的阴影
// view.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(25, 50, 100, 100) cornerRadius:10].CGPath;
// //设置图片
// view.layer.contents = (id)[UIImage imageNamed:@"image"].CGImage;
//
// //设置边框
// view.layer.borderWidth = 2;
// //设置边框颜色
// view.layer.borderColor = [UIColor purpleColor].CGColor;
//
// [self.window addSubview:view];
//
//与UIView一样,CALayer只是没有事件响应,其实是UIView依赖CALayer
CALayer *layer = [[CALayer alloc] init];
layer.backgroundColor = [UIColor yellowColor].CGColor;
layer.frame = CGRectMake(60, 250, 200, 200);
[self.window.layer addSublayer:layer];
CALayer *subLayer = [[CALayer alloc] init];
subLayer.backgroundColor = [UIColor redColor].CGColor;
subLayer.frame = CGRectMake(0, 0, 100, 100);
[layer addSublayer:subLayer];
NSLog(@"%@",layer);
NSLog(@"%@",subLayer.superlayer);
return YES;
}