Created
December 25, 2023 04:38
-
-
Save amosgyamfi/86c20a8a6b1d354e0c3525bd564ef390 to your computer and use it in GitHub Desktop.
Create different types of rectangular shapes in SwiftUI
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
// | |
// CreateRectangularShapes.swift | |
// ThousandDaysOfSwiftUI | |
import SwiftUI | |
struct CreateRectangularShapes: View { | |
var body: some View { | |
NavigationStack { | |
VStack { | |
// 1. Rectangle | |
Rectangle() | |
.frame(width: 100, height: 100) | |
// 2. Rounded rectangle with corner radius and style | |
RoundedRectangle(cornerRadius: /*@START_MENU_TOKEN@*/25.0/*@END_MENU_TOKEN@*/, style: .continuous) | |
.frame(width: 100, height: 100) | |
// 3. Rounded rectangle with corner size and style | |
RoundedRectangle(cornerSize: CGSize(width: 20, height: 10), style: .circular) | |
.frame(width: 100, height: 100) | |
// 4. Uneven rounded rectangle | |
UnevenRoundedRectangle(topLeadingRadius: 30, bottomLeadingRadius: 0, bottomTrailingRadius: 30, topTrailingRadius: 0, style: .continuous) | |
.frame(width: 100, height: 100) | |
} | |
.navigationTitle("Creating Rectangular shapes") | |
.navigationBarTitleDisplayMode(.inline) | |
} | |
} | |
} | |
#Preview { | |
CreateRectangularShapes() | |
.preferredColorScheme(.dark) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment