iOS 《CORE ANIMATION ADVANCED TECHNIQUES》 学习笔记
引入两个类拓展 UIView+LM.h 和 CALayer+LMXYWH.h
http://www.jianshu.com/p/03d38e6e25f9
#import "ViewController.h"
@interface ViewController ()
@property (strong,nonatomic)UIView *layerView;
@end
@implementation ViewController
#pragma mark - 控制器生命周期
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
}
#pragma mark - setupUI
-(void)setupUI
{
self.view.backgroundColor = [UIColor grayColor];
self.layerView = [[UIView alloc]init];
self.layerView.backgroundColor = [UIColor whiteColor];
self.layerView.W = 200;
self.layerView.H = 200;
self.layerView.center = SCREEN_CENTER;
[self.view addSubview:self.layerView];
//给视图添加一个蓝色子视图
CALayer *blueLayer = [CALayer layer];
blueLayer.backgroundColor = [UIColor blueColor].CGColor;
blueLayer.frame = CGRectMake(50, 50, 100, 100);
[self.layerView.layer addSublayer:blueLayer];
}
@end
QQ20170416-232531.png
网友评论