Figma에 있는 shadow 동일하게 구현하는 법

How to control shadow spread and blur?

헷갈리는 CALayer.shadow 관련 옵션

figma 또는 디자인에서 표현식
x,y,blur,color(rgba 0,0,0,0.3)

shadowoffset(width: x, height: y)
shadowRadius = blur
shadowColor = color.gcclorl // default is blakc

UIBezierPath 성능 향상?

뷰를 두개 사용하는 방안에 비해서 하나의 뷰에 서브레이어를 삽입하므로서 한개로 줄일 수 있음

Untitled

insertSublayer vs addSublayer

// self.pathView.layer.addSublayer(shadowLayer)

(lldb) po self.pathView.layer
<CALayer:0x283535100; position = CGPoint (207 648); bounds = CGRect (0 0; 207 179); delegate = <UIView: 0x10360c780; frame = (103.5 558.5; 207 179); layer = <CALayer: 0x283535100>>; sublayers = (<CAShapeLayer: 0x28353e780>); opaque = YES; allowsGroupOpacity = YES; >

(lldb) po self.pathView.layer.sublayers
▿ Optional<Array<CALayer>>
  ▿ some : 1 element
    - 0 : <CAShapeLayer:0x28353e780; position = CGPoint (0 0); bounds = CGRect (0 0; 0 0); allowsGroupOpacity = YES; shadowOpacity = 0.5; shadowOffset = CGSize (3 3); shadowRadius = 8; shadowColor = <CGColor 0x28160d590> [<CGColorSpace 0x281110900> (kCGColorSpaceICCBased; kCGColorSpaceModelMonochrome; Generic Gray Gamma 2.2 Profile; extended range)] ( 0 1 ); shadowPath = <CGPath 0x28070c510>; fillColor = <CGColor 0x28110d080> [<CGColorSpace 0x28110cea0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 0 0 1 1 ); path = <CGPath 0x28070c480>>
// self.pathView.layer.insertSublayer(shadowLayer, at: 0)

(lldb) po self.pathView.layer.sublayers
▿ Optional<Array<CALayer>>
  ▿ some : 1 element
    - 0 : <CAShapeLayer:0x2800f4940; position = CGPoint (0 0); bounds = CGRect (0 0; 0 0); allowsGroupOpacity = YES; shadowOpacity = 0.5; shadowOffset = CGSize (3 3); shadowRadius = 8; shadowColor = <CGColor 0x2823b71b0> [<CGColorSpace 0x2824ac7e0> (kCGColorSpaceICCBased; kCGColorSpaceModelMonochrome; Generic Gray Gamma 2.2 Profile; extended range)] ( 0 1 ); shadowPath = <CGPath 0x2832a41b0>; fillColor = <CGColor 0x2824b5320> [<CGColorSpace 0x2824ac120> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 0 0 1 1 ); path = <CGPath 0x2832a4120>>

(lldb) po self.pathView.layer
<CALayer:0x280087600; position = CGPoint (207 648); bounds = CGRect (0 0; 207 179); delegate = <UIView: 0x149e0b540; frame = (103.5 558.5; 207 179); layer = <CALayer: 0x280087600>>; sublayers = (<CAShapeLayer: 0x2800f4940>); opaque = YES; allowsGroupOpacity = YES; >

<aside> 💡 아 그냥 인서트와 에드의 차이인가보네 insert는 인덱스 위치까지 지정해서 넣어줄 수 있고, add는 느낌상 push인듯

</aside>

&ref

How To Programmatically Add Shadow and Rounded Corners to a View - Swift

Swift Tip: Adding Rounded Corners and Shadows to a UIView

GradientView