Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Easily customizable floating button menu created with SwiftUI

License

NotificationsYou must be signed in to change notification settings

exyte/FloatingButton

Repository files navigation

     

FloatingButton

Easily customizable floating button menu created with SwiftUI

SPMCocoapodsLicense: MIT

Usage

  1. Create main button view and a number of submenu buttons — both should be cast toAnyView type.

  2. Pass both toFloatingButton constructor:

    FloatingButton(mainButtonView: mainButton, buttons: buttons)
  3. You may also pass a binding which will determine if the menu is currently open. You may use this to close the menu on any submenu button tap for example.

FloatingButton(mainButtonView: mainButton, buttons: buttons, isOpen: $isOpen)
  1. Chain.straight() or.circle() to specify desired menu type.
  2. Chain whatever you like afterwards. For example:
    FloatingButton(mainButtonView: mainButton, buttons: textButtons).straight().direction(.top).alignment(.left).spacing(10).initialOffset(x:-1000).animation(.spring())FloatingButton(mainButtonView: mainButton2, buttons: buttonsImage.dropLast()).circle().startAngle(3/2*.pi).endAngle(2*.pi).radius(70).layoutDirection(.counterClockwise)

Universal options

spacing - space between submenu buttons
initialScaling - size multiplyer for submenu buttons when the menu is closed
initialOffset - offset for submenu buttons when the menu is closed
initialOpacity - opacity for submenu buttons when the menu is closed
animation - custom SwiftUI animation likeAnimation.easeInOut() orAnimation.spring()
delays - delay for each submenu button's animation start- you can pass array of delays - one for each element- or you can passdelayDelta - then this same delay will be used for each elementmainZStackAlignment - main button and submenu buttons are contained in one ZStack (not an overlay so the menu has a correct size), you can change this ZStack's alignment with this parameterinverseZIndex - inverse zIndex of mainButton and the children. Use, for example, if you have a negative spacing and want to change the orderwholeMenuSize - pass CGSize binding to get updates of menu's size. Menu's size includes main button frame and all of elements' framesmenuButtonsSize - pass CGSize binding to get updates of combined menu elements' size

Straight menu only options

direction - position of submenu buttons relative to main menu button
alignment - alignment of submenu buttons relative to main menu button

Circle only options

startAngle
endAngle
radius - distance between center of main button and centers of submenu buttons
layoutDirection - changes the button layout direction from the startAngle to the endAngle

Examples

To try the FloatingButton examples:

  • Clone the repohttps://github.com/exyte/FloatingButton.git
  • OpenFloatingButtonExample.xcodeproj in the Xcode
  • Try it!

Installation

dependencies:[.package(url:"https://github.com/exyte/FloatingButton.git")]

Requirements

  • iOS 14.0+ / macOS 11.0+ / watchOS 7.0+
  • Xcode 12+

Our other open source SwiftUI libraries

PopupView - Toasts and popups library
AnchoredPopup - Anchored Popup grows "out" of a trigger view (similar to Hero animation)
Grid - The most powerful Grid container
ScalingHeaderScrollView - A scroll view with a sticky header which shrinks as you scroll
AnimatedTabBar - A tabbar with a number of preset animations
MediaPicker - Customizable media picker
Chat - Chat UI framework with fully customizable message cells, input view, and a built-in media picker
OpenAI Wrapper lib forOpenAI REST API
AnimatedGradient - Animated linear gradient
ConcentricOnboarding - Animated onboarding flow
ActivityIndicatorView - A number of animated loading indicators
ProgressIndicatorView - A number of animated progress indicators
FlagAndCountryCode - Phone codes and flags for every country
SVGView - SVG parser
LiquidSwipe - Liquid navigation animation

About

Easily customizable floating button menu created with SwiftUI

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors7

Languages


[8]ページ先頭

©2009-2026 Movatter.jp