zjf
2023-03-13 881f0da670f20c401c1e1d08b36253abb28f72d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
//  UIImageView+CSCategory.m
//  ChinaSub
//
//  Created by zjf on 2019/10/23.
//  Copyright © 2019 probim. All rights reserved.
//
 
#import "UIImageView+CSCategory.h"
 
@implementation UIImageView (CSCategory)
- (void)circleImage {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        CAShapeLayer *cornerLayer = [CAShapeLayer layer];
        UIBezierPath *cornerPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:self.bounds.size.width/2];
        cornerLayer.path = cornerPath.CGPath;
        cornerLayer.frame = self.bounds;
        self.layer.mask = cornerLayer;
    });
}
- (void)circleImageWithRadius:(NSInteger)radius {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        CAShapeLayer *cornerLayer = [CAShapeLayer layer];
        UIBezierPath *cornerPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:radius];
        cornerLayer.path = cornerPath.CGPath;
        cornerLayer.frame = self.bounds;
        self.layer.mask = cornerLayer;
    });
}
@end