SegmentedButton
欢迎来到 SegmentedButton,这是一个 UI/UX 框架,允许用户快速轻松地插入模拟分割按钮,如 iOS 13 中 Apple Maps 应用中的分屏样式按钮。
屏幕截图
功能
- 超级高效
- 预构建 UI(阴影、圆角等)
- 支持原生的深色/浅色模式。
使用
import SegmentedButton
class ViewController: UIViewController{
func foo() {
//Setup Location Button
locationButton.tintColor = .buttonTintColor
locationButton.setImage(UIImage(named: "ic_location")?.withRenderingMode(.alwaysTemplate), for: .normal)
locationButton.addTarget(self, action: #selector(zoomMapToUserLocation), for: .touchUpInside)
locationButton.contentEdgeInsets = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0)
//Setup Settings Button
settingsButton.tintColor = .buttonTintColor
settingsButton.setImage(UIImage(named: "settingsIcon")?.withRenderingMode(.alwaysTemplate), for: .normal)
settingsButton.addTarget(self, action: #selector(openSettings), for: .touchUpInside)
settingsButton.contentEdgeInsets = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0)
//Setup Split Button View
let splitButton: SplitButton = SplitButton(buttons: [locationButton, settingsButton])
self.view.addSubview(splitButton)
//Update Split Button Constraints
splitButton.snp.makeConstraints { (make) in
make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(16)
make.right.equalToSuperview().inset(16)
}
}
}
要求
- iOS 11.0+
- Xcode 9.0+
通讯
- 如果您需要帮助,请使用 Stack Overflow。 (标签 'segmentedbutton')
- 如果您想提出一个 一般性问题,请使用 Stack Overflow。
- 如果您发现了一个 bug,并且能提供可靠的复现步骤,请提交一个 issue。
- 如果您有 功能需求,请提交一个 issue。
- 如果您想 贡献,请提交一个 pull request。
安装
嵌入式框架需要 iOS 11 及以上最低部署目标。
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。您可以通过以下命令安装它
$ gem install cocoapods
使用 CocoaPods 将 SegmentedButton 的功能集成到您的 Xcode 项目中,请在您的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!
pod 'SegmentedButton', '~> 0.1.0'
然后,运行以下命令
$ pod install
变更日志
SegmentedButton 是一个不断发展的项目,在其开发过程中可能会遇到变化。建议在更新版本之前查阅 变更日志。
许可
Apache 2.0 许可
版权所有 (C) 2020, Ordermentum Pty Ltd 保留所有权利。
本软件按“原样”提供,不提供任何形式的保证,无论是明示的还是默示的,包括但不限于适销性、适用于特定目的和不侵犯权利的保证。在任何情况下,作者或版权所有者均不对此软件或由此软件、使用或与之相关的任何索赔、损害或其他责任承担责任,无论责任是在合同行为、侵权行为或其他方式中产生的。