在iOS应用程序中创建浮动菜单 [英] Creating a floating menu in an iOS application

查看:171
本文介绍了在iOS应用程序中创建浮动菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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





我最初的想法是扩展UIViewController类,并在那里添加相应的绘图/逻辑,但是,应用程序由一些其他控制器组成,更具体地说是UITableViewController,它本身扩展了UIViewController。也许是一个扩展的好地方?或者是否有一种更有说服力的方式在特定视图上绘制菜单而没有菜单相关代码的大量复制?



菜单本身将显示在大多数屏幕上,所以我需要有选择地启用它。根据用户当前所在的视图/屏幕,它也会有些上下文。



有什么好主意吗?

解决方案

您可以使用动画和所有内容创建自己的,或者您可以查看此库




Looking to create a floating menu in Swift for an iOS application I am developing. Something along the lines of the little red circle menu as shown in the following image.

My initial thoughts were to extend the UIViewController class and add the respective drawing/logic there, however, the application is comprised of a few other controllers, more specifically the UITableViewController which in itself extends UIViewController. Is there perhaps a good place for an extension perhaps? Or is there a more eloquent way of drawing the menu on specific views without the mass duplication of menu related code?

The menu itself will be shown on most screens, so I need to selectively enable it. It'll also be somewhat contextual based on the view/screen the user is currently on.

Any awesome ideas?

解决方案

You can create your own with the animations and all the things, or you can check this library

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() }
    }

这篇关于在iOS应用程序中创建浮动菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆