//
//  CALayer+DDCategory.m
//  DDCategoryKit_Private
//  Created by DDIsFriend on 2022/7/29.

#import "CALayer+DDCategory.h"

@implementation CALayer (DDCategory)
+ (CALayer *)dd_layerWithShadowColor:(CGColorRef)shadowColor shadowOffset:(CGSize)shadowOffset shadowRadius:(CGFloat)shadowRadius shadowOpacity:(CGFloat)shadowOpacity  cornerRadius:(CGFloat)cornerRadius layerBackground:(nullable CGColorRef)layerBackground{
    CALayer *layer = [CALayer layer];
    
    layer.shadowColor = shadowColor;
    layer.shadowOffset = shadowOffset;
    layer.shadowRadius = shadowRadius;
    layer.shadowOpacity = shadowOpacity;
    
    layer.cornerRadius = cornerRadius;
    
    layer.backgroundColor = layerBackground;
    
    layer.shouldRasterize = YES;
    layer.rasterizationScale = UIScreen.mainScreen.scale;
    return layer;
}

- (void)dd_layerWithShadowColor:(CGColorRef)shadowColor shadowOffset:(CGSize)shadowOffset shadowRadius:(CGFloat)shadowRadius shadowOpacity:(CGFloat)shadowOpacity  cornerRadius:(CGFloat)cornerRadius layerBackground:(nullable CGColorRef)layerBackground{
    if (!self) return ;
    
    self.shadowColor = shadowColor;
    self.shadowOffset = shadowOffset;
    self.shadowRadius = shadowRadius;
    self.shadowOpacity = shadowOpacity;
    
    self.cornerRadius = cornerRadius;
    
    self.backgroundColor = layerBackground;
    
    self.shouldRasterize = YES;
    self.rasterizationScale = UIScreen.mainScreen.scale;
}
@end
