Open wangkecheng opened 7 years ago
这样子根本都没有圆角,但是把 cornerRadius设置为35 isBlur设置为YES后就有,Bug太多,又特别难改
我修改了一下,遇到类似的小伙伴,处理方式 1.将 typedef void(^LWAsyncCompleteBlock)();替换为 typedef void(^LWAsyncCompleteBlock)(LWImageStorageimageStorage,CALayer layer); 2.替换后会遇到很多报错,不要怕,报错主要在LWAsyncImageView+Display.m方法中,这个方法中的所有completion(),都替换为completion(imageStorage,self.layer) 3.替换完成后,到LWAsyncImageView.m ->setImageStoragesResizeBlock方法-> [container lw_setImageWihtImageStorage:imageStorage resize:resizeBlock completion:nil];替换为 [container lw_setImageWihtImageStorage:imageStorage resize:resizeBlock completion:^(LWImageStorage imageStorage, CALayer layer) {
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:imageStorage.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft| UIRectCornerBottomRight cornerRadii:CGSizeMake(imageStorage.cornerRadius, imageStorage.cornerRadius)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = imageStorage.bounds;
maskLayer.path = maskPath.CGPath;
layer.mask = maskLayer;
}];即可
4.思路:拿到LWAsyncImageView的layer,对这个layer进行设置