@@ -17,34 +17,34 @@ extension ShadowView{
1717 }
1818
1919 let imageView = UIImageView ( )
20- imageView. frame. size = self . frame. size. scaled ( by: shadowScale)
21- imageView. center = CGPoint ( x: self . bounds. midX, y: self . bounds. midY)
20+ imageView. frame. size = frame. size. scaled ( by: shadowScale)
21+ imageView. center = CGPoint ( x: bounds. midX, y: bounds. midY)
2222 imageView. layer. masksToBounds = false
23- self . shadowImageView = imageView
24- self . insertSubview ( imageView, at: 0 )
23+ shadowImageView = imageView
24+ insertSubview ( imageView, at: 0 )
2525 }
2626
2727
2828
2929 func updateShadow( ) {
3030
3131 self . shadowImageView. image = nil
32- DispatchQueue . global ( qos: DispatchQoS . QoSClass. utility) . async {
33- self . createLayerImage ( )
32+ DispatchQueue . global ( qos: DispatchQoS . QoSClass. utility) . async { [ weak self ] in
33+ self ? . createLayerImage ( )
3434 }
3535 }
3636
3737 private func createLayerImage( ) {
3838
39- let image = self . asImage
39+ let image = asImage
4040 let containerLayer = CALayer ( )
4141 let imageSize = image. size
42- containerLayer. frame = CGRect ( origin: . zero, size: imageSize. scaled ( by: self . scaleImageConstant) )
42+ containerLayer. frame = CGRect ( origin: . zero, size: imageSize. scaled ( by: scaleImageConstant) )
4343 containerLayer. backgroundColor = UIColor . clear. cgColor
4444 let blurImageLayer = CALayer ( )
4545 blurImageLayer. frame = CGRect ( origin: . zero, size: imageSize)
4646 blurImageLayer. position = CGPoint ( x: containerLayer. bounds. midX, y: containerLayer. bounds. midY)
47- blurImageLayer. contents = image. applyBlurWithRadius ( 0 , tintColor: self . shadowColor, saturationDeltaFactor: self . shadowSaturation) ? . cgImage
47+ blurImageLayer. contents = image. applyBlurWithRadius ( 0 , tintColor: shadowColor, saturationDeltaFactor: shadowSaturation) ? . cgImage
4848
4949 blurImageLayer. masksToBounds = false
5050 containerLayer. addSublayer ( blurImageLayer)
@@ -53,15 +53,15 @@ extension ShadowView{
5353
5454 let resizeImageConstant : CGFloat = 1
5555 guard let resizedContainerImage = containerImage. resized ( withPercentage: resizeImageConstant) ,
56- let blurredImage = resizedContainerImage. applyBlur ( blurRadius: self . blurRadius)
56+ let blurredImage = resizedContainerImage. applyBlur ( blurRadius: blurRadius)
5757 else {
5858 return
5959 }
6060
61- self . layer. masksToBounds = false
61+ layer. masksToBounds = false
6262
63- DispatchQueue . main. async {
64- self . shadowImageView? . image = blurredImage
63+ DispatchQueue . main. async { [ weak self ] in
64+ self ? . shadowImageView? . image = blurredImage
6565 }
6666
6767 }
0 commit comments