Created
December 30, 2021 21:13
-
-
Save c-villain/c91b9bfb02205979e8b31d5f3e7235cb to your computer and use it in GitHub Desktop.
Must-have SwiftUI frame extensions
This file contains 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 { | |
// MARK: Vertical Center | |
func vCenter() -> some View { | |
self | |
.frame(maxHeight: .infinity, alignment: .center) | |
} | |
// MARK: Vertical Top | |
func vTop() -> some View { | |
self | |
.frame(maxHeight: .infinity, alignment: .top) | |
} | |
// MARK: Vertical Bottom | |
func vBottom() -> some View { | |
self | |
.frame(maxHeight: .infinity, alignment: .bottom) | |
} | |
// MARK: Horizontal Center | |
func hCenter() -> some View { | |
self | |
.frame(maxWidth: .infinity, alignment: .center) | |
} | |
// MARK: Horizontal Leading | |
func hLeading() -> some View { | |
self | |
.frame(maxWidth: .infinity, alignment: .leading) | |
} | |
// MARK: Horizontal Trailing | |
func hTrailing() -> some View { | |
self | |
.frame(maxWidth: .infinity, alignment: .trailing) | |
} | |
} |
@ggoraa enjoy!=)
https://github.com/ggoraa/SwiftUIUtils created a Swift Package for things like this :D
@ggoraa nice one!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These are super useful! Thanks!