您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页iOS | Sheeter: 一个基于xib的Swift动作表单

iOS | Sheeter: 一个基于xib的Swift动作表单

来源:二三娱乐

要求

  • Xcode 8.3+
  • Swift 3.2+
  • iOS 9.0+

介绍

SheeterDropDown
  • 这个控件有点类似于UIKit里的UIPopoverController(已被废弃),它可以实现基于一个sourceView的任意位置的显示,是基于UIViewController的。
  • SheeterDropDown采用了类似的设计方式,但实现和使用比较简单。
  • 用法:
  1. 默认的列表样式
DropDown Default
Sheeter.dropDown(from: sender, items: [
    "Drop Down Item1",
    "Drop Down Item2",
    "Drop Down Item3"
]) 
// 这里是点击回调
{ (selected) in
    print(selected)
}
  1. 自定义view(viewController)样式
DropDown Custom
Sheeter.dropDown(from: sender, customView: xxx)
SheeterActionSheet
  • 显而易见的,这个控件和UIKit里的UIAlertController设置style为.actionSheet后是一模一样的。
  1. 默认的列表样式
ActionSheet Default
Sheeter.actionSheet(items: [
    "Action Sheet Item1",
    "Action Sheet Item2"
])
// 回调
{ (selected) in
    print(selected)
}
  1. 自定义view(viewController)样式
ActionSheet Custom
// 使用
Sheeter.dropDown(from: sender, customView: actionCollectionVC.view)

// 自定义view的controller
fileprivate var actionCollectionVC: ActionCollectionVC{
    let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ActionCollectionVC") as! ActionCollectionVC
    vc.view.frame = CGRect(origin: .zero, size: CGSize(width: view.bounds.width, height: 100))
    vc.collectionView?.delegate = self
    return vc
}

// 代理方法
extension ViewController: UICollectionViewDelegate{
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        print("You clicked Action Item \(indexPath.item)")
    }
}

Carthage

  • 目前该控件库已上传到github上,支持Carthage编译
  • 用法

1.在你的Cartfile中加入
github "BackWorld/Sheeter" "master"

2.在终端执行carthage update

3.将Carthage/Build/iOS目录下的Sheeter.framework拖到你的项目中

4.在使用的swift文件中import Sheeter即可

Github

iPhoneX

iPhoneX适配

如果对你有帮助,别忘了点个赞和关注~

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务