Skip to content

A native, colored and all-SwiftUI exit button icon.

Notifications You must be signed in to change notification settings

joogps/ExitButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ExitButton Dark icon Light icon

Twitter: @joogps

A simple, native SwiftUI exit icon made with SF Symbols, with colors and sizes that exactly match Apple's.

Home app gif Share sheet gif

As seen in the Home app and iOS share sheet

Installation

This repository is a Swift package, so you can just include it in your app through the Swift Package Manager. Alternatively, you can just copy the custom view to your project and it will work just as fine:

struct ExitButtonView: View {
    @Environment(\.colorScheme) var colorScheme
    
    var body: some View {
        ZStack {
            Circle()
                .fill(Color(white: colorScheme == .dark ? 0.19 : 0.93))
            Image(systemName: "xmark")
                .resizable()
                .scaledToFit()
                .font(Font.body.weight(.bold))
                .scaleEffect(0.416)
                .foregroundColor(Color(white: colorScheme == .dark ? 0.62 : 0.51))
        }
    }
}

Usage

Usage is incredibly straight forward. Just import the component and instantiate the view like this:

import ExitButton

ExitButtonView()

and frame it like this:

ExitButtonView().frame(width: 24, height: 24)

or use it as a button, like this:

Button(action: { presentationMode.wrappedValue.dismiss() }) {
  ExitButtonView()
}.frame(width: 24, height: 24)

About

A native, colored and all-SwiftUI exit button icon.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages