//
|
// 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
|