CATransform3D立体效果演示

很久之前看过一篇讲CATransform3D的文章,现在找不到了...,这个效果是文章里面的,现在重新实现一下这个效果。


- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIScrollView *scroll = [UIScrollView new];
    scroll.frame = [UIScreen mainScreen].bounds;
    scroll.backgroundColor = [UIColor blackColor];
    scroll.contentSize = CGSizeMake(scroll.bounds.size.width*3, scroll.bounds.size.width*3);
    [self.view addSubview:scroll];
    
    //设置父图层的sublayerTransform属性的m34值,那么所有的子图层都会生效,且共同享有一个灭点
    CATransform3D transform = CATransform3DIdentity;
    transform.m34 = -1.0 / 500;
    scroll.layer.sublayerTransform = transform;
    
    
    int row = 5;
    int col = 5;
    int level = 11;
    int wight = 50;
    int margin = 30;
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        for (int i=0; i

你可能感兴趣的:(CATransform3D立体效果演示)