Member-only story

Floating button in SwiftUI

Nicola De Filippo
2 min readApr 30, 2024
Image generated with ChatGPT

The Apple User Interface Guidelines don’t mention floating buttons, and there is no native component for them. However, some applications, such as Twitter and the Gmail client, do use them.

In this post, we’ll explore how to create a floating button, taking the Gmail app client as our example.

We aim to create this:

Therefore, we need to create a TabView. Inside the first tab, we’ll use a ZStack that contains both a list and a button.

struct ContentView: View {
var body: some View {
TabView {
NavigationStack {
ZStack {
List(initList(), id:\.self) { mail in
Text(mail)
}
VStack {
Spacer()
HStack {
Spacer()
NavigationLink { EmptyView()} label:{
Image(systemName: "pencil")
.font(.title.weight(.semibold))
.padding()
.background(.pink)
.foregroundStyle(.white)…

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Nicola De Filippo
Nicola De Filippo

Written by Nicola De Filippo

Software Engineer and Entrepreneur

No responses yet

Write a response