gpt4 book ai didi

ios - 在 iOS 应用程序中创建 float 菜单

转载 作者:可可西里 更新时间:2023-11-01 00:15:11 26 4
gpt4 key购买 nike

希望在 Swift 中为我正在开发的 iOS 应用程序创建一个 float 菜单。如下图所示,沿着红色小圆圈菜单的线条。

enter image description here

我最初的想法是扩展 UIViewController 类并在其中添加相应的绘图/逻辑,但是,该应用程序由一些其他 Controller 组成,更具体地说是 UITableViewController,它本身扩展了 UIViewController。也许有一个扩展的好地方吗?或者是否有更 Eloquent 方式在特定 View 上绘制菜单而无需大量重复菜单相关代码?

菜单本身会显示在大多数屏幕上,因此我需要有选择地启用它。它还会根据用户当前所在的 View /屏幕在某种程度上与上下文相关。

有什么好主意吗?

最佳答案

你可以用动画和所有东西创建你自己的,或者你可以查看这个库

https://github.com/lourenco-marinho/ActionButton

var actionButton: ActionButton!

override func viewDidLoad() {
super.viewDidLoad()

let twitterImage = UIImage(named: "twitter_icon.png")!
let plusImage = UIImage(named: "googleplus_icon.png")!

let twitter = ActionButtonItem(title: "Twitter", image: twitterImage)
twitter.action = { item in println("Twitter...") }

let google = ActionButtonItem(title: "Google Plus", image: plusImage)
google.action = { item in println("Google Plus...") }

actionButton = ActionButton(attachedToView: self.view, items: [twitter, google])
actionButton.action = { button in button.toggleMenu() }
}

enter image description here

关于ios - 在 iOS 应用程序中创建 float 菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31979342/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com