All Projects → quassum → SwiftUI-Tooltip

quassum / SwiftUI-Tooltip

Licence: MIT license
Easy Tooltip for your SwiftUI Project

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to SwiftUI-Tooltip

aprenda-swift
Uma lista de conteúdos para você aprender Swift
Stars: ✭ 429 (+230%)
Mutual labels:  apple, swiftui, swift5
StoreHelper
Implementing and testing In-App Purchases with StoreKit2 and StoreHelper in Xcode 13, Swift 5.5, SwiftUI, iOS 15 and macOS 12.
Stars: ✭ 158 (+21.54%)
Mutual labels:  swiftui, swift5
Harbour
Docker/Portainer management app for iOS
Stars: ✭ 210 (+61.54%)
Mutual labels:  swiftui, swift5
Shift
Light-weight EventKit wrapper.
Stars: ✭ 31 (-76.15%)
Mutual labels:  swiftui, swift5
BottomSheet
A sliding Sheet from the bottom of the Screen with 3 States build with SwiftUI.
Stars: ✭ 597 (+359.23%)
Mutual labels:  swiftui, swift5
stinsen
Coordinators in SwiftUI. Simple, powerful and elegant.
Stars: ✭ 563 (+333.08%)
Mutual labels:  swiftui, swift5
iOS-SwiftUI-Firebase-Login-Example
Complete Sign up and Sign in Process for iOS SwiftUI - using Firebase Email and Password Authentication.
Stars: ✭ 37 (-71.54%)
Mutual labels:  swiftui, swift5
SwiftUIDemo
A demo app showing you how to build a table view and navigation interface with SwiftUI
Stars: ✭ 26 (-80%)
Mutual labels:  swiftui, swift5
SwiftUIFormValidator
Declarative form validator for SwiftUI.
Stars: ✭ 34 (-73.85%)
Mutual labels:  apple, swiftui
GameKitUI.swift
GameKit (GameCenter) for SwiftUI
Stars: ✭ 29 (-77.69%)
Mutual labels:  swiftui, swift5
ScrollViewProxy
ScrollViewProxy for SwiftUI on iOS 13 and up
Stars: ✭ 135 (+3.85%)
Mutual labels:  apple, swiftui
QuoteKit
A framework to use the free APIs provided by https://quotable.io
Stars: ✭ 17 (-86.92%)
Mutual labels:  swiftui, swift5
JewelCase
This is the source code for JewelCase, a sample app demonstrating how to use SwiftUI and Firebase together. This slide deck discusses the architecture of the app: https://www.slideshare.net/peterfriese/building-swiftui-apps-with-firebase
Stars: ✭ 42 (-67.69%)
Mutual labels:  swiftui, swift5
LongWeekend-iOS
🏖📱 LongWeekend is iOS Application that supports checking long weekends when taking a vacation in Japan
Stars: ✭ 19 (-85.38%)
Mutual labels:  swiftui, swift5
Windows11
💻 Windows 11 in SwiftUI.
Stars: ✭ 177 (+36.15%)
Mutual labels:  swiftui, swift5
SimpleToast
SimpleToast is a simple, lightweight, flexible and easy to use library to show toasts / popup notifications inside iOS or MacOS applications in SwiftUI. Because of the flexibility to show any content it is also possible to use the library for showing simple modals.
Stars: ✭ 131 (+0.77%)
Mutual labels:  swiftui, swift5
Open Source Ios Apps
📱 Collaborative List of Open-Source iOS Apps
Stars: ✭ 28,826 (+22073.85%)
Mutual labels:  apple, swiftui
Wwdc
You don't have the time to watch all the WWDC session videos yourself? No problem me and many contributors extracted the gist for you 🥳
Stars: ✭ 2,561 (+1870%)
Mutual labels:  apple, swiftui
SwiftUI-App
This swiftUI Demo is very simple & easy to understand. This swiftUI demo includes On-boarding screens, login screen, forgot password screen, sign up screen, home & logout.
Stars: ✭ 175 (+34.62%)
Mutual labels:  swiftui, swift5
SwiftUI-Currency-Converter
Currency Converter project coded by SwiftUI and Swift5
Stars: ✭ 56 (-56.92%)
Mutual labels:  swiftui, swift5

SwiftUI Tooltip

Workflow checks Release version License

"Buy Me A Coffee"

This package provides you with an easy way to show tooltips over any SwiftUI view, since Apple does not provide one.

preview

Getting started

You can add this package to your project using Swift Package Manager. Enter following url when adding it to your project package dependencies:

https://github.com/quassum/SwiftUI-Tooltip.git

We are using semver for versioning, so we would recomment selecting "Up to next major relase" option for this package.

After you added the package, all you need to do is import it and you can add a tooltip to any SwiftUI View in that file!

Usage

Basic use case

As the first example, the Text view is provided as the tooltip content and it's attached to the other Text view. Below you can see the example of code that is required to create the tooltip and the result you see on the screen.

Code:

import SwiftUITooltip
...
Text("Say something nice...")
    .tooltip(.bottom) {
        Text("Something nice!")
    }
...

Result:

example 1

Controlling whether the tooltip is present

You can cantrol whether the tooltip is presented or not through the _ enabled: Binding<Bool> argument. Below you can see an example of how this would look like.

@State var tooltipVisible = false
...
Button("Toggle tooltip") {
    self.tooltipVisible = !self.tooltipVisible
}
...
Text("I'm the confusing text.")
    .tooltip(self.tooltipVisible) {
        Text("I'm the text explaining the confusing text.")
    }

Using custom configuration to add a jumping animation

Second example shows you how you can add jumping animation to the tooltip from the first example.

Code:

import SwiftUI
import SwiftUITooltip

struct SwiftUIView: View {
    var tooltipConfig = DefaultTooltipConfig()
    
    init() {
        self.tooltipConfig.enableAnimation = true
        self.tooltipConfig.animationOffset = 10
        self.tooltipConfig.animationTime = 1
    }
    
    var body: some View {
        Text("Say something nice...")
            .tooltip(.bottom, config: tooltipConfig) {
                Text("Something nice!")
            }
    }
}

Result:

example 2

Configuration Reference

Below you can see all the properties that you can set in the configuration.

Property Type Description
side TooltipSide Side of view that the tooltip should appear on
margin CGFloat Margin from the tooltip to the view it's attached to
borderRadius CGFloat Rounded border control
borderWidth CGFloat Thickness of the border
borderColor Color Border color
backgroundColor Color Background color inside of the tooltip
contentPaddingLeft CGFloat Left padding inside of the tooltip
contentPaddingRight CGFloat Right padding inside of the tooltip
contentPaddingTop CGFloat Top padding inside of the tooltip
contentPaddingBottom CGFloat Bottom padding inside of the tooltip
showArrow Bool Whether to show or hide the arrow
arrowWidth CGFloat Width of the base of the triangle
arrowHeight CGFloat Height of the triangle
enableAnimation Bool Whether to bounce the tooltip or not
animationOffset CGFloat Delay between tooltip bouncing animations
animationTime Double How long should the tooltip bounce last

Contributing

If you like this package but feel that you need more control or custom implementation - feel free to open an issue, send a pull request or fork the repo!

Reward function: Contributors with even smallest PRs will be added to the list in the Contributors section!

Contributors

License

This package is licensed under MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].