Skip to content

Latest commit

 

History

History
36 lines (31 loc) · 964 Bytes

valentine.md

File metadata and controls

36 lines (31 loc) · 964 Bytes

Be mine SwiftUI

Screen Shot 2023-02-14 at 4 00 29 PM

try? it out

import SwiftUI

struct RatingView: View {
    let stars = 5
    let fixedStars = Array(0...4)
    var body: some View {
        VStack {
            Text("SwiftUI can you be my Valentine?")
                .padding()
            HStack {
                ForEach(Array(fixedStars.enumerated()),
                        id: \.offset) { index, element in
                    Image(systemName: index < stars ? "heart.fill" : "heart")
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                        .frame(width: 44)
                        .foregroundColor(.red)
                }
            }
        }
    }
}

struct RatingView_Previews: PreviewProvider {
    static var previews: some View {
        RatingView()
    }
}