NeumorphismTab is custom TabBarController with Neumorphism design.
- Implement custom tab with neumorphism.
- UIView extension which add neumorphism shadow to any views.
- Xcode 11.0 or greater
- iOS 11 or greater
- Swift 5.1
If you're using Carthage, simply add
NeumorphismTab to your Cartfile
:
github "touyou/NeumorphismTab"
NeumorphismTab is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'NeumorphismTab'
NeumorphismTab is available through SwiftPM
, create Package.swift
and add dependencies
value
dependencies: [
.package(url: "https://github.com/touyou/NeumorphismTab.git", from: "0.9.6")
]
or you can use GUI based SPM with Xcode 11.
Like this.
Code is this.
import UIKit
import NeumorphismTab
class DemoTabBarController: NeumorphismTabBarController {
override func setupView() {
let color = UIColor(hex: "C1D2EB")
let home = NeumorphismTabBarItem(icon: UIImage(systemName: "house.fill")!, title: "Home")
let favorite = NeumorphismTabBarItem(icon: UIImage(systemName: "heart.fill")!, title: "")
view.backgroundColor = color
let homeViewController: ViewController = {
let viewController = ViewController.instantiate()
viewController.view.backgroundColor = color
return viewController
}()
let favoriteViewController: UIViewController = {
let viewController = UIViewController()
viewController.view.backgroundColor = color
return viewController
}()
setTabBar(items: [home, favorite])
viewControllers = [homeViewController, favoriteViewController]
}
}
NeumorphismTabBarController needs same background color throughout all view and ViewControllers. In particular, a luminance of the color should be within 0.18 to 0.88.
addNeumorphismShadow(with:)
can add neumorphism to any view. with
is parent of the view.
let color = UIColor(hex: "C1D2EB")
view.backgroundColor = color
childView.backgroundColor = color
childView.layer.cornerRadius = childView.bounds.width / 2
childView.layer.maskedCorners = [.layerMaxXMaxYCorner, .layerMaxXMinYCorner, .layerMinXMaxYCorner]
childView.addNeumorphismShadow(with: view)
Override it if you want to adjust tab margin of horizontal.
Override it if you want to adjust tab margin of bottom.
You must override it and setup ViewControllers and tab by calling setTabBar method here.
Override it if you want to implement some feature when switching tab.
If you set some color here, it can reset neumorphism shadow color with set color.
When you use NeumorphismTabBarController, you should instantiate ViewControllers by code because you can setup it only in setupView
method.
StoryboardInstantiate
protocol enable you to use Storyboard and instantiate by code easily.
You should write like this:
extension ViewController: StoryboardInstantiable {}
Then you should create new storyboard named ViewController's name (e.g. ViewController.storyboard
), and make layout and set is initial view controller
true.
Now you can instantiate ViewController like this:
let viewController = ViewController.instantiate()
You can use UIColor initializer by hex string. You must not include #
if you use it.
NeumorphismTab is available under the MIT license. See the LICENSE file for more info.