![frontPhoto](https://private-user-images.githubusercontent.com/73422344/258637276-ae547bee-8da3-4e14-aa92-57a3e44396fc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU4OTYwODQsIm5iZiI6MTcyNTg5NTc4NCwicGF0aCI6Ii83MzQyMjM0NC8yNTg2MzcyNzYtYWU1NDdiZWUtOGRhMy00ZTE0LWFhOTItNTdhM2U0NDM5NmZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA5VDE1Mjk0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYwMzQxZTM0NjhjMTk0YzI1ZDE0NTFmNmViNDZjM2UyMGIwMWRiNzkxMTNmNWM4M2ExNzE5NzEyYmUwZTUwZTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Mf9f2aGm3XXQGJptZZ3M8k3DYluf-5PHgOmrm5DlGpw)
Neumorphism is a design style using shadows below or above the elements to make convex or concave effects.
- iOS 11.0+
Use Swift Package Manager by adding following line to Package.swift
:
dependencies: [
.package(url: "https://github.com/Chaehui-Seo/CHNeumorphismView.git", from: "0.0.2")
]
Make UIView as neumorphism view by changing the Custom Class to CHNeumorphismView
.
Default CHNeumorphismView would look like below.
Curve Direction | Intensity | Dark Shadow Color | Light Shadow Color |
---|---|---|---|
Outside (Convex) | 1 (Maximum value) | Based on background Color | White |
![defaultValue](https://private-user-images.githubusercontent.com/73422344/258637397-bbefdd7c-1b90-4439-8f34-6fa3f885b1b0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU4OTYwODQsIm5iZiI6MTcyNTg5NTc4NCwicGF0aCI6Ii83MzQyMjM0NC8yNTg2MzczOTctYmJlZmRkN2MtMWI5MC00NDM5LThmMzQtNmZhM2Y4ODViMWIwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA5VDE1Mjk0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIyMDA3ODI1M2E5MTVkZWY1YTllNjgwZDE5YTkzMmY2YjJiYTY4NjZiN2MwMWQ3ZWViYjg3ZjQ5ZWMwNTFiNjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.awwPipWjokMPbxzEPPRJ9JKjDfT4U_OyImhzDvLCEHE)
All of the customizing options can be set either in the storyboard or with codes.
You can change it in the storyboard by set the value of the inspectors like below.
You can apply the effect with various options at once with public method.
// MARK: - [Make Neumorphism Effect at once]
// Curve Direction is the only essential parameter.
neumorphismView.makeNeumorphismEffect(curve: .outside) // for outside curve (= convex)
neumorphismView.makeNeumorphismEffect(curve: .inside) // for inside curve (= concave)
// Intensity is not essential and the default value is 1, which is the maximum value.
// Intensity value can be set between 0 ~ 1
neumorphismView.makeNeumorphismEffect(curve: .outside, intensity: 0.8)
// Dark or light shadow color can be set as you want.
// If you don't set the color value, dark shadow color will be decided based on the background color,
// and light shadow color will be set as white.
neumorphismView.makeNeumorphismEffect(curve: .inside, intensity: 0.8, darkShadowColor: UIColor.gray)
neumorphismView.makeNeumorphismEffect(curve: .inside, intensity: 0.8, lightShadowColor: UIColor.yellow)
neumorphismView.makeNeumorphismEffect(curve: .inside, intensity: 0.8, darkShadowColor: UIColor.gray, lightShadowColor: UIColor.yellow)
Or you can modity the options one by one.
// MARK: - [Curve Direction]
neumorphismView.isCurveOutside = true // for outside curve (= convex)
neumorphismView.isCurveOutside = false // for inside curve (= concave)
// MARK: - [Effect Intensity]
neumorphismView.effectIntensity = 0.5 // value between 0 ~ 1, default value is 1
// MARK: - [Corner Radius]
neumorphismView.cornerRadius = 10 // Use it rather than 'layer.cornerRadius' to apply corner to the effect
// MARK: - [Shadow Color]
neumorphismView.darkShadowColor = UIColor( ... ) // default value is set based on the background color
neumorphismView.lightShadowColor = UIColor( ... ) // default value is .white
You can run SampleApp Project located in SampleApp
folder.
All the functions that provided by the package are testable through the SampleApp project.
Make sure to apply the effect AFTER setting the layout of the target view.