Home > AI > IOS > SwiftUI >

(Effect) ListRow with shadow background


import SwiftUI

struct SectionListRowView: View {
    static let screenWidth = UIScreen.main.bounds.size.width
    static let screenHeight = UIScreen.main.bounds.size.height
    static let screenSize = UIScreen.main.bounds.size
    
    var abbreviate: String
    var name: String
    var comment: String = "AI"
    
    var body: some View {
        ZStack {

            Color.white
                    .edgesIgnoringSafeArea(.all)
            HStack() {
                Text(abbreviate)
                    .foregroundColor(.blue)
                    .font(.system(size: 13))
                    .frame(width: SectionListRowView.screenWidth*0.9*0.1, height: 20, alignment: .center)
                    .overlay(
                        RoundedRectangle(cornerRadius: 5)
                            .stroke(Color.blue, lineWidth: 1)
                )
                Text(name)
                    .font(.system(size: 13))
                    .frame(width: SectionListRowView.screenWidth*0.9*0.5, height: 20, alignment: .leading)
                Text(comment)
                    .font(.system(size: 13))
                    .foregroundColor(.blue)
                    .frame(width: SectionListRowView.screenWidth*0.9*0.3, height: 20, alignment: .trailing)
            }.padding()
        }
        .padding()
        .cornerRadius(5)
            .frame(width: SectionListRowView.screenWidth*0.9, height: 60, alignment: .center)
        .shadow(radius: 5)
        
    }
}

Leave a Reply