您的位置:首页 > 产品设计 > UI/UE

Xcode7.2核心动画Layer的简单认识使用

2015-12-26 12:01 501 查看
1、在@interface中声明一个View;

<span style="font-size:24px;">@property (weak, nonatomic) IBOutlet UIView *redView;</span>


2、利用控件的Layer属性进行操作,如设置圆角半径、阴影、背景色等等;

<span style="font-size:24px;">_redView.layer.cornerRadius = 50;//圆角半径
//    _redView.layer.masksToBounds = YES;
_redView.layer.borderWidth = 2;
_redView.layer.borderColor = [UIColor whiteColor].CGColor;
_redView.layer.shadowColor = [UIColor yellowColor].CGColor;
_redView.layer.shadowOffset = CGSizeMake(10, 10);
_redView.layer.shadowOpacity = 1;</span>

3、创建一个黄色的长方形View,并设置其Layer;

<span style="font-size:24px;">UIView * rectView = [[UIView alloc]initWithFrame:CGRectMake(100, 300, 100, 200)];
[self.view addSubview:rectView];
rectView.backgroundColor = [UIColor yellowColor];
rectView.layer.cornerRadius = 50;</span>

效果如图:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息