Skip to content

Latest commit

 

History

History
62 lines (50 loc) · 1.91 KB

README.md

File metadata and controls

62 lines (50 loc) · 1.91 KB

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)