欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

【Swift】类似于微博、微信的ActionSheet

发布时间:2025/3/17 编程问答 32 豆豆
生活随笔 收集整理的这篇文章主要介绍了 【Swift】类似于微博、微信的ActionSheet 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

1、 PGActionSheet使用了UITableView进行复用 2、为了更好的融合当前的界面,PGActionSheet默认的弹出框的透明度是0.7

GitHub 地址:

https://github.com/xiaozhuxiong121/PGActionSheet

CocoaPods安装

pod 'PGActionSheet' 复制代码

使用

let actionSheet = PGActionSheet(cancelButton: true, buttonList: ["收藏", "保存", "编辑"]) present(actionSheet, animated: false, completion: nil) 复制代码

有两种方式监听点击事件 1、闭包

actionSheet.handler = {index inprint("index = ", index) } 复制代码

2、代理

func actionSheet(_ actionSheet: PGActionSheet, clickedButtonAt index: Int) {print("index = ", index) } 复制代码

设置title

actionSheet.actionSheetTitle = "PGActionSheet" 复制代码

取消弹出框的透明度

actionSheet.actionSheetTranslucent = false 复制代码

取消背景的半透明

actionSheet.translucent = false 复制代码

自定义显示字的样式

actionSheet.textFont = UIFont.boldSystemFont(ofSize: 20) actionSheet.textColor = UIColor.orange 复制代码

自定义取消按钮的样式

actionSheet.cancelTextColor = UIColor.blue actionSheet.cancelTextFont = UIFont.systemFont(ofSize: 20) 复制代码

自定义title的样式

actionSheet.actionSheetTitleFont = UIFont.boldSystemFont(ofSize: 22) actionSheet.actionSheetTitleColor = UIColor.red 复制代码

转载于:https://juejin.im/post/5a312cdf6fb9a04514640afd

总结

以上是生活随笔为你收集整理的【Swift】类似于微博、微信的ActionSheet的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。