GitHub - mcasashi-aso/Neumorphismic
source link: https://github.com/mcasashi-aso/Neumorphismic
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
Neumorphismic
Neumorphism is next design theory. This library make easy to made SwiftUI app with Neumorphism.
Requirements
- Xcode 11.0 or later
- iOS 13 or tvOS 13 or macOS 10.15 or watchOS 6 or later
- Swift 5.1
Installation
Swift Package Manager
Open your Xcode project, select File
-> Swift Packages
-> Add Package Dependency...
. and type this depository's URL.
How to use
Simple way
struct ContentView: View { let baseColor = Color(hex: "C1D2EB") var body: some View { ZStack { baseColor .edgesIgnoringSafeArea(.all) Circle() .fill(baseColor) .frame(width: 300, height: 200) .modifier(NMConvexModifier()) .environment(\.nmBaseColor, baseColor) } } }
If you want modify NMConvexModifier
to components using Binding
, you must modify to it's background view.
TextField("C1D2EB", text: $model.userInput) .foregroundColor(baseColor.nmPrimary(1)) .padding(5) .background( RoundedRectangle(cornerRadius: 5, style: .continuous) .fill(baseColor) .modifier(NMConvexModifier(radius: 9)) )
And when you modify to other components, you should modify too because for performance. There is detail of usage in Demo_iOS
.
FloatingTabView
Neumorphismic contains FloatingTabView
.
enum Tab: String, Hashable, CaseIterable { case demo = "Demo" case settings = "Settings" func image() -> Image { switch self { case .demo: return Image(systemName: "house") case .settings: return Image(systemName: "gear") } } func view() -> some View { VStack { if self == .demo { DemosView() } else { SettingsView() } } } } struct ContentView: View { @State var selection: Tab = .demo var body: some View { NMFloatingTabView( selection: $selection, verticalPadding: 34, horizontalPadding: UIDevice.current.hasRoundedDisplay ? 0 : 34, labelText: { tab in tab.rawValue }, labelImage: { tab in tab.image() } ) { tab in tab.view() } .environment(\.nmBaseColor, Color(hex: "C1D2EB")) } }
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK