测试测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年11月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 MinMao 维护。
MMShareSheet 是一个简单的弹出选择框,使用纯 Swift 编写,类似于微信(或支付宝)里面的分享(朋友圈打开网页右上角分享)控件
MMShareSheet 是一个简单的弹出选择框(ShareSheet),使用纯 Swift 编写。类似于微信(或支付宝)的动作表单分享-UIKit
克隆代码,然后将 components 文件夹下的两个文件 MMShareSheet.swift
和 MMCardItem.swift
添加到您的项目中。
只需克隆并添加 MMShareSheet.swift
和 MMCardItem.swift
到您的项目中。
【类似于微信分享】- 类似于微信分享
【单组卡片】- 单组卡片(显示组数完全取决于传入的卡片数组)
【多组卡片】- 多组卡片
【支持远程图标】- 支持远程图标
let cards = [
[
[
"title": "微信好友",
"icon": "wechat",
"handler": "wxfriend"
],[
"title": "微信朋友圈",
"icon": "moment",
"handler": "wxmoment"
],[
"title": "QQ好友",
"icon": "qq",
"handler": "qqfriend",
],[
"title": "支付宝",
"icon": "airpay",
"handler": "airpay",
],[
"title": "新浪微博",
"icon": "sina",
"handler": "sinawb",
]
],[
[
"title": "拷贝",
"icon": "copy_link",
"handler": "copy"
],[
"title": "在Safari中打开",
"icon": "safari",
"handler": "safari"
],[
"title": "收藏",
"icon": "collection",
"handler": "collect",
],[
"title": "刷新",
"icon": "refresh_icon",
"handler": "refresh",
],[
"title": "举报",
"icon": "jubao",
"handler": "report",
]
]
]
let cancelBtn = [
"title": "取消",
"handler": "cancel",
"type": "default",
]
let mmShareSheet = MMShareSheet.init(title: "此网页由wx.keeponrunning.com提供", cards: cards, duration: nil, cancelBtn: cancelBtn)
mmShareSheet.callBack = { (handler) ->() in
print(handler)
}
mmShareSheet.present()
PS:注释
MMShareSheet.init(title: "此网页由wx.keeponrunning.com提供", cards: cards, duration: nil, cancelBtn: cancelBtn)
参数描述【参数描述】
title
头部标题
cards
事件按钮数组,类型为Array<Array<Dictionary<String, String>>>
,其中包含每一行卡片组Array<Dictionary<String, String>>
,每一行卡片中又包含 item <Dictionary<String, String>>:
[
"title": "拍照",
"icon": "wechat"
"handler": "camera",
]
title
item 标题icon
item 图标,可以是本地图片名或远程图片链接handler
item 事件唯一标识,回调时根据该值来区别处理事件duration
动画时长
cancelBtn
取消按钮属性,类型为 <Dictionary<String, String>
;如果设置为 nil
则没有该按钮,必须设置一个属性,默认值为 [ "title": "取消", "handler": "cancel", "type": "default"]
回调【回调】
mmShareSheet.callBack = { (handler) ->() in
print(handler)
}
handler
该 handler 即为 cards 中 item 的 handler
,对应的回调过来
mmShareSheet.present()
欢迎使用 fork 并提交 pull request。
MMShareSheet 是遵守 MIT 许可的开源软件。