Skip to content

Commit 37f34fa

Browse files
author
Duc Nguyen
committed
Update README
1 parent 248f779 commit 37f34fa

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
# RoundShadowView
22
Easy way to create the Round Shadow View
33

4-
![](Simulator Screen Shot - iPhone X - 2019-01-13 at 11.15.50.png)
4+
Override layoutSubviews to add a new layer using a path with a roundedRect and cornerRadius
5+
```
6+
override func layoutSubviews() {
7+
super.layoutSubviews()
8+
layer.cornerRadius = cornerRadius
9+
addShadowLayer()
10+
}
11+
12+
func addShadowLayer() {
13+
14+
guard shadowLayer == nil else { return }
15+
16+
shadowLayer = CAShapeLayer()
17+
shadowLayer.path = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
18+
shadowLayer.fillColor = backgroundColor?.cgColor ?? UIColor.white.cgColor
19+
shadowLayer.shadowColor = shadowColor.cgColor
20+
shadowLayer.shadowPath = shadowLayer.path
21+
shadowLayer.shadowOffset = shadowOffset
22+
shadowLayer.shadowOpacity = shadowOpacity
23+
shadowLayer.shadowRadius = shadowRadius
24+
25+
layer.insertSublayer(shadowLayer, at: 0)
26+
}
27+
```
28+
<!--- ![](Simulator Screen Shot - iPhone X - 2019-01-13 at 11.15.50.png) --->
29+
30+
<img src="Simulator%20Screen%20Shot%20-%20iPhone%20X%20-%202019-01-13%20at%2011.15.50.png" alt="" width="300">

ShadowRoundCorner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
89605E8621EADAA90066F526 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 89605E8521EADAA90066F526 /* Assets.xcassets */; };
1414
89605E8921EADAA90066F526 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 89605E8721EADAA90066F526 /* LaunchScreen.storyboard */; };
1515
89605E9121EADB7F0066F526 /* RoundShadowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89605E9021EADB7F0066F526 /* RoundShadowView.swift */; };
16+
89605E9321EB05D30066F526 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 89605E9221EB05D30066F526 /* README.md */; };
1617
/* End PBXBuildFile section */
1718

1819
/* Begin PBXFileReference section */
@@ -24,6 +25,7 @@
2425
89605E8821EADAA90066F526 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2526
89605E8A21EADAA90066F526 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2627
89605E9021EADB7F0066F526 /* RoundShadowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundShadowView.swift; sourceTree = "<group>"; };
28+
89605E9221EB05D30066F526 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
2729
/* End PBXFileReference section */
2830

2931
/* Begin PBXFrameworksBuildPhase section */
@@ -40,6 +42,7 @@
4042
89605E7221EADAA80066F526 = {
4143
isa = PBXGroup;
4244
children = (
45+
89605E9221EB05D30066F526 /* README.md */,
4346
89605E7D21EADAA80066F526 /* ShadowRoundCorner */,
4447
89605E7C21EADAA80066F526 /* Products */,
4548
);
@@ -127,6 +130,7 @@
127130
files = (
128131
89605E8921EADAA90066F526 /* LaunchScreen.storyboard in Resources */,
129132
89605E8621EADAA90066F526 /* Assets.xcassets in Resources */,
133+
89605E9321EB05D30066F526 /* README.md in Resources */,
130134
89605E8421EADAA80066F526 /* Main.storyboard in Resources */,
131135
);
132136
runOnlyForDeploymentPostprocessing = 0;

ShadowRoundCorner/RoundShadowView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class RoundShadowView: UIView {
5757
override func layoutSubviews() {
5858
super.layoutSubviews()
5959
layer.cornerRadius = cornerRadius
60-
print(#function)
6160
addShadowLayer()
6261
}
6362

0 commit comments

Comments
 (0)