Created
March 18, 2020 17:59
-
-
Save ivangodfather/6b96bc3e0c6e57b98bf1d66a531ad946 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension View { | |
| func badge(num: Int) -> some View { | |
| return self.overlay( | |
| // ZStack(alignment: .topTrailing) { | |
| Circle() | |
| .fill(Color.red) | |
| .frame(width: 24, height: 24) | |
| .overlay(Text(num.description)) | |
| .transition(.scale) | |
| .alignmentGuide(.trailing) { dim -> CGFloat in | |
| return dim[HorizontalAlignment.center] | |
| } | |
| .alignmentGuide(.top) { dim -> CGFloat in | |
| return dim[VerticalAlignment.center] | |
| } | |
| //}.background(Color.yellow) | |
| , alignment: .topTrailing) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment