ALActionController 0.0.9

ALActionController 0.0.9

Anton Lobanov 维护。



  • 作者:
  • alobanov11

ALActionController

自定义操作表控制器.

如果您喜欢这个项目,不要忘记给它 star ★ 并在 GitHub 上关注我

导航

安装

Swift 包管理器

Swift 包管理器 是一个用于管理 Swift 代码分发的工具。它集成到 Swift 构建系统中,以自动执行下载、编译和链接依赖项的过程。

要使用 Xcode 12 将 ALActionController 集成到您的项目中,请在 文件 > Swift 包 > 添加包依赖... 中指定它。

https://github.com/alobanov11/ALActionController

CocoaPods

CocoaPods是一款Cocoa项目的依赖管理器。有关使用和安装说明,请访问他们的网站。要使用CocoaPods将ALActionController集成到您的Xcode项目中,请在您的Podfile中指定它。

pod 'ALActionController'

手动操作

如果您不希望使用任何依赖管理器,您可以将ALActionController手动集成到项目中。将Sources/ALActionController文件夹放入您的Xcode项目中。请确保启用按需复制项创建分组

快速开始

首先,您需要呈现不带动画的控制器。

let actionController = ALActionController(
  actions: [
    .init(title: "Privacy policy"),
    .init(title: "Settings"),
    .init(title: "Logout"),
    .init(title: "Cancel", style: .cancel),
  ]
)

self.present(actionController, animated: false, completion: nil)

用法

ALActionController具有可完全自定义的属性。您可以轻松地为自己设置它。

let actionController = ALActionController(
  actions: [
    .init(title: "Privacy policy", selected: true, icon: #imageLiteral(resourceName: "icon3")),
    .init(title: "Settings", icon: #imageLiteral(resourceName: "icon4")),
    .init(title: "Logout", icon: #imageLiteral(resourceName: "icon5"), handler: { [weak self] in self?.onLogout?() }),
    .init(title: "Cancel", style: .cancel),
  ],
  styles: .init(
    itemStyles: .init(
      contentInsets: .init(top: 16, left: 20, bottom: 16, right: 20),
      height: 54,
      cornerRadius: 10,
      backgroundColor: .init(rgb: 0x3A343C),
      tintColor: .init(rgb: 0x7F7980),
      selectedTintColor: .init(rgb: 0xB57FFF),
      cancelTintColor: .white,
      separatorColor: UIColor(rgb: 0x7F7980).withAlphaComponent(0.1),
      separatorHeight: 1,
      font: .systemFont(ofSize: 16),
      horizontalAlignment: .left,
      iconTitlePadding: 16
    ),
    backgroundColor: UIColor.black.withAlphaComponent(0.8),
    contentInsets: .init(top: 0, left: 10, bottom: 0, right: 10),
    sectionInsets: .init(top: 0, left: 0, bottom: 10, right: 0)
  )
)
self.present(actionController, animated: false, completion: nil)