iOS CALayer创建


    //创建一个图层
    CALayer *layer = [CALayer layer];
    layer.backgroundColor = [UIColor redColor].CGColor;
    layer.frame = CGRectMake(50, 50, 100, 100);
    layer.cornerRadius = 14;
    layer.masksToBounds = YES;
    //必须强制转成 id 类型
    layer.contents = (id)[UIImage imageNamed:@"1.png"].CGImage;





你可能感兴趣的:(iOS CALayer创建)