| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 | ////  UIView+PublicInit.m//  Asteria////  Created by iOS on 2023/4/24.//#import "UIView+PublicInit.h"@implementation UIView (PublicInit)// MARK: - base create+ (UIView *)baseV {    UIView *v = [[UIView alloc] init];    v.backgroundColor = UIColor.whiteColor;    return v;}+ (UILabel *)baseLb {    UILabel *lb = [[UILabel alloc] init];//    lb.font = [UIFont fontWithName:Rob_Regular size:14];    lb.textColor = [UIColor blackColor];    lb.backgroundColor = [UIColor clearColor];    return lb;}+ (UIImageView *)baseImgV {    UIImageView *imgV = [[UIImageView alloc] init];    imgV.contentMode = UIViewContentModeScaleAspectFit;    return imgV;}+ (UIStackView *)baseStackV:(BOOL)isVertical {    UIStackView *stackV = [[UIStackView alloc] init];    stackV.axis = isVertical ? UILayoutConstraintAxisVertical : UILayoutConstraintAxisHorizontal;    stackV.spacing = 8;    stackV.alignment = UIStackViewAlignmentFill;    stackV.distribution = UIStackViewDistributionFill;    return stackV;}+ (void)viewAddLineColorBg:(UIView *)bgV colorArr:(NSArray *)colors {    CAGradientLayer *layer = [[CAGradientLayer alloc] init];    layer.frame = bgV.bounds;    layer.colors = colors;    layer.startPoint = CGPointMake(0.22, 0.14);    layer.endPoint = CGPointMake(0.8, 0.82);    layer.locations = @[@0,@1.0f];    layer.name = @"colorLayer";    layer.cornerRadius = 4;    [bgV.layer addSublayer:layer];}+ (void)viewAddHorColorBg:(UIView *)bgV colorArr:(NSArray *)colors {    CAGradientLayer *layer = [[CAGradientLayer alloc] init];    layer.frame = bgV.bounds;    layer.colors = colors;    layer.startPoint = CGPointMake(0, 0.47);    layer.endPoint = CGPointMake(1, 0.45);    layer.locations = @[@0,@1.0f];    layer.name = @"colorLayer";    layer.cornerRadius = 4;    [bgV.layer addSublayer:layer];}+ (void)viewAddHorColorBg:(UIView *)bgV colorArr:(NSArray *)colors startP:(CGPoint)start endP:(CGPoint)end {    CAGradientLayer *layer = [[CAGradientLayer alloc] init];    layer.frame = bgV.bounds;    layer.colors = colors;    layer.startPoint = start;    layer.endPoint = end;    layer.locations = @[@0,@1.0f];    layer.name = @"colorLayer";//    layer.cornerRadius = 4;    [bgV.layer addSublayer:layer];}+ (UIImage *)snapshotWithView:(UIView *)view {    UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [UIScreen mainScreen].scale);    [view.layer renderInContext:UIGraphicsGetCurrentContext()];    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();    return image;}+ (UIVisualEffectView *)getBlurV:(CGRect)frame {    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];        effectView.frame = frame;    return effectView;}- (void)setLayerShadow:(UIColor*)color offset:(CGSize)offset radius:(CGFloat)radius {    self.layer.shadowColor = color.CGColor;    self.layer.shadowOffset = offset;    self.layer.shadowRadius = radius;    self.layer.shadowOpacity = 1;    self.layer.shouldRasterize = YES;    self.layer.rasterizationScale = [UIScreen mainScreen].scale;}@end
 |