iOS编程 CALayer
2015-07-03 16:15
176 查看
UIVIEW---》CALAYER--->主层 次层
//
// ViewController.m
// 070304layer
//
// Created by tianshangrenjian on 15/7/3.
// Copyright © 2015年 tianshangrenjian. All rights reserved.
//
#import "ViewController.h"
@interface
ViewController ()
@property (weak,
nonatomic) IBOutlet
UIView *SCHView;
@property (weak,
nonatomic) IBOutlet
UIImageView *iconView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CALayer *layer=self.SCHView.layer;
layer.backgroundColor=[UIColor
redColor].CGColor;
// layer.borderColor=[UIColor blueColor].CGColor;
// layer.borderWidth=6;
layer.cornerRadius=5;
layer.shadowColor=[UIColor
blackColor].CGColor;//阴影
layer.shadowOffset=CGSizeMake(10,
4);
layer.shadowOpacity=0.8;
CALayer *sublayer=[[CALayer
alloc] init];
// layer.masksToBounds=YES;//限制自层的范围在该层内
sublayer.frame=CGRectMake(20,
20, 40,
540);
sublayer.backgroundColor=[UIColor
greenColor].CGColor ;
[layer
addSublayer:sublayer];
self.iconView.layer.cornerRadius=80;
self.iconView.layer.masksToBounds=YES;
self.iconView.image=[UIImage
imageNamed:@"IMG_0004.jpg"];
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// ViewController.m
// 070304layer
//
// Created by tianshangrenjian on 15/7/3.
// Copyright © 2015年 tianshangrenjian. All rights reserved.
//
#import "ViewController.h"
@interface
ViewController ()
@property (weak,
nonatomic) IBOutlet
UIView *SCHView;
@property (weak,
nonatomic) IBOutlet
UIImageView *iconView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CALayer *layer=self.SCHView.layer;
layer.backgroundColor=[UIColor
redColor].CGColor;
// layer.borderColor=[UIColor blueColor].CGColor;
// layer.borderWidth=6;
layer.cornerRadius=5;
layer.shadowColor=[UIColor
blackColor].CGColor;//阴影
layer.shadowOffset=CGSizeMake(10,
4);
layer.shadowOpacity=0.8;
CALayer *sublayer=[[CALayer
alloc] init];
// layer.masksToBounds=YES;//限制自层的范围在该层内
sublayer.frame=CGRectMake(20,
20, 40,
540);
sublayer.backgroundColor=[UIColor
greenColor].CGColor ;
[layer
addSublayer:sublayer];
self.iconView.layer.cornerRadius=80;
self.iconView.layer.masksToBounds=YES;
self.iconView.image=[UIImage
imageNamed:@"IMG_0004.jpg"];
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
相关文章推荐
- 一步一步教你做ios推送
- iOS开发属性与成员变量的区别
- IOS 序列化与反序列化
- IOS中的基础动画CABasicAnimation的运用指南
- ios开发,让界面只响应单个点击事件
- 联想Win7笔记本通过BIOS禁止开机声音步骤
- archive的时候报“ no identity found"错误 解决方案
- iOS 9 适配系列教程
- iOS圆形按钮
- ipad 升级iOS8
- iOSKVC KVO 添加观察者 --销毁的时候要删除观察者
- Win8系统进不了BIOS无法对BIOS进行修改怎么办
- iOS 开发使用16进制色值设置颜色
- iOS之CF和OC之间类型转换
- iOS 程序crash控制台输入命令调试
- iOS 实现gif 图片效果 以及 图片不变形处理
- iOS进入后台长时间运行后台任务
- iOS开发关于block学习的总结
- iOS 异常处理
- iOS点击空白处关闭presentViewController出来的view