欢迎光临
我们一直在努力

可交互、无限个数、支持回弹、自定义的圆弧菜单

建站超值云服务器,限时71元/月

可交互、无限个数、支持回弹、自定义的圆弧菜单

项目介绍:

https://github.com/CatchZeng/InteractiveCircularMenu

InteractiveCircularMenu

Version
License
Platform

Interactive, springback, customizable(color, width, speed, angles) circular menu.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

InteractiveCircularMenu is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'InteractiveCircularMenu'

Concept

StartAngleOffset

SpeedRatio

Interactive speed, default is 1.0 .

CircularWidth

SpacingAngle

MaxAngle

The max angle you can scroll.

MinAngle

The min angle you can scroll.

MaxSpringbackAngle

The max angle for springback, default is maxAngle-spacingAngle.

MinSpringbackAngle

The min angle for springback, default is minAngle+spacingAngle.

Usage

Init InteractiveCircularMenu and set dataSource & delegate

menuView.dataSource = self
menuView.delegate = self

Set menu color your like.

menuView.menuColor = UIColor.white

Reload when dataSource changed.

menuView.reload()

Implement dataSource & delegate

extension ViewController: InteractiveCircularMenuDataSource {
    func numberOfItems(in menu: InteractiveCircularMenu) -> Int {
        return items.count
    }

    func menu(_ menu: InteractiveCircularMenu, itemAt index: Int) -> CircularMenuItem {
        return items[index]
    }
}

extension ViewController: InteractiveCircularMenuDelegate {
    func menu(_ menu: InteractiveCircularMenu, didSelectAt index: Int) {
        AlertControllerBuilder(title: "Tip",
                               message: "Click:\(index+1)").addAction(title: "OK") { (_) in
        }.build().show()
    }

    func circularWidth(in menu: InteractiveCircularMenu) -> CGFloat {
        return 80
    }

    func menu(_ menu: InteractiveCircularMenu, itemSizeAt index: Int) -> CGSize {
        let width = circularWidth(in: menu)
        return CGSize(width: width*0.9, height: width*0.9)
    }

    func startAngleOffset(_ menu: InteractiveCircularMenu) -> CGFloat {
        return 60
    }

    func spacingAngle(_ menu: InteractiveCircularMenu) -> CGFloat {
        return 30
    }

    func maxAngle(_ menu: InteractiveCircularMenu) -> CGFloat {
        return startAngleOffset(menu) + 2*spacingAngle(menu)
    }

    func minAngle(_ menu: InteractiveCircularMenu) -> CGFloat {
        let offset = startAngleOffset(menu)
        let spacing = spacingAngle(menu)
        return offset-spacing*CGFloat(items.count-1)
    }
}

Author

catchzeng, catchzenghh@gmail.com

License

InteractiveCircularMenu is available under the MIT license. See the LICENSE file for more info.

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 可交互、无限个数、支持回弹、自定义的圆弧菜单
分享到: 更多 (0)