NeumorphismKit
NeumorphismKit 是 UIKit 的圆角阴影风格框架。
要求
- iOS 12.0+
- Swift 5.1+
版本
NeumorphismKit 版本 | Xcode 版本 |
---|---|
1.0.0 | Xcode 11+ |
1.1.0 | Xcode 12+ |
安装
CocoaPods
要使用 CocoaPods 将 NeumorphismKit 集成到您的 Xcode 项目中,请指定它位于您的 Podfile
中
platform :ios, '12.0'
use_frameworks!
target '<TargetName>' do
pod 'NeumorphismKit', '~> 1.0'
end
然后,运行以下命令:
$ pod install
Carthage
要使用 Carthage 将 NeumorphismKit 集成到你的 Xcode 项目中,请在你的 Cartfile
中指定它
github "y-okudera/NeumorphismKit" ~> 1.0
运行 carthage update
命令以构建框架,并将构建好的 NeumorphismKit.framework
拖入你的 Xcode 项目中。
使用方法
Storyboard
你可以在 Storyboard 上启动 NeumorphismKit。
- 将 'NeumorphismButton' 设置为 UIButton 的自定义类。
- 将按钮的基本颜色设置为 SuperView 的背景颜色。
代码
你还可以在代码中启动 NeumorphismKit。
let neumorphismButton = NeumorphismButton(frame: .init(x: 0, y: 0, width: 120.0, height: 40.0))
neumorphismButton.baseColor = self.view.backgroundColor ?? .white
neumorphismButton.center = self.view.center
neumorphismButton.setTitle("BUTTON", for: .normal)
let titleColor = UIColor(red: 160 / 255, green: 70 / 255, blue: 255 / 255, alpha: 1.0)
neumorphismButton.setTitleColor(titleColor, for: .normal)
self.view.addSubview(neumorphismButton)
NeumorphismTabBarController
当使用 NeumorphismTabBarController 时,实现继承的类。
import NeumorphismKit
import UIKit
class YourTabBarController: NeumorphismTabBarController {
override func viewDidLoad() {
super.viewDidLoad()
self.nskDelegate = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// If it is an empty string, the title will be hidden.
let btn1 = NeumorphismTabBarItem(title: "", icon: UIImage(named: "your_tab_img1")!)
let btn2 = NeumorphismTabBarItem(title: "", icon: UIImage(named: "your_tab_img2")!)
let btn3 = NeumorphismTabBarItem(title: "", icon: UIImage(named: "your_tab_img3")!)
let btn4 = NeumorphismTabBarItem(title: "Timeline", icon: UIImage(named: "your_tab_img4")!)
let btn5 = NeumorphismTabBarItem(title: "Users", icon: UIImage(named: "your_tab_img5")!)
// Set tuples for viewController and NeumorphismTabBarItem.
self.setup(viewControllers: [
(viewController: MainViewController.instantiate(), tabBarItem: btn1),
(viewController: OtherViewController.instantiate(text: "View1"), tabBarItem: btn2),
(viewController: OtherViewController.instantiate(text: "View2"), tabBarItem: btn3),
(viewController: OtherViewController.instantiate(text: "View3"), tabBarItem: btn4),
(viewController: OtherViewController.instantiate(text: "View4"), tabBarItem: btn5),
])
}
}
extension YourTabBarController: NeumorphismTabBarControllerDelegate {
// Delegate when switching tabs.
func finishedSwitchingTab(fromIndex: Int, toIndex: Int) {
print("fromIndex: \(fromIndex) toIndex: \(toIndex)")
}
}
然后在你的 Storyboard 中设置 YourTabBarController。
还可以使用其他组件。请参阅 演示项目。
作者
Yuki Okudera, [email protected]
许可证
NeumorphismKit 在 MIT 许可证下可用。有关更多信息,请参阅许可证文件。