Skip to content

Instantly share code, notes, and snippets.

@joogps
Created October 10, 2020 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joogps/574e5d4d829f5669d2a77bf9c922f285 to your computer and use it in GitHub Desktop.
Save joogps/574e5d4d829f5669d2a77bf9c922f285 to your computer and use it in GitHub Desktop.
Quick and easy negative text label with colored background in SwiftUI
import SwiftUI
struct TextMask: View {
var body: some View {
Color.white
.frame(maxHeight: 30)
.mask(Text("Today")
.font(.system(size: 12, weight: .heavy))
.padding(.vertical, 7)
.padding(.horizontal, 15)
.background(Color.white)
.cornerRadius(26)
.luminanceToAlpha())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment