Learn Courses My Dashboard

Shdow in swiftUI

I got this issue when I used shdow in swiftUI:
WARNING The layer is using dynamic shadows which are expensive to render. If possible try setting shadowPath, or pre-rendering the shadow into an image and putting it under the layer.

Share the code in which you are trying to apply a shadow.

       ForEach(mvm.m_array) { movie in
                        VStack{
                            if movie.image != nil{
                                Image(movie.image!)
                                    .resizable()
                                    .frame(width: UIScreen.main.bounds.width - 110, height: 450, alignment: .center)
                                    //.offset(x: -20)
                                    .cornerRadius(10)
                                    .shadow(color: .black,radius: 8)
                                    .padding(.top,5)
                            }
                            else{
                                Image(uiImage: movie.image2!)
                                    .resizable()
                                    .frame(width: UIScreen.main.bounds.width - 70, height: 450, alignment: .center)
                                    //.offset(x: -20)
                                    .cornerRadius(10)
                                    .shadow(color: .black,radius: 8)
                                    .padding(.top,5)
                                
                            }
                            HStack{
                                Text(movie.movieName)
                                    .font(Font.system(size: 12, design: .monospaced))
                                    .frame(width: 200, height: 20)
                                    .background(Color.yellow)
                                    .cornerRadius(10)
                                    .shadow(color: .black,radius: 8)
                                
                                Spacer()
                                HStack{
                                    Image(systemName: "star.fill")
                                        .resizable()
                                        .frame(width: 15, height: 15)
                                        .foregroundColor(.yellow)
                                    Text("\(movie.rank)")
                                        .font(Font.system(size: 12, design: .monospaced))
                                    
                                }.frame(width: 60, height: 17)
                                .background(Color.white)
                                .cornerRadius(10)
                                .shadow(color:.black,radius: 10)
                                .offset(x: -10)
                                
                            }.padding(.leading)
                            HStack{
                                Text(movie.category)
                                    .font(Font.system(size: 10, design: .monospaced))
                                    .frame(width: 200, height: 15)
                                    .background(Color.white)
                                    .cornerRadius(10)
                                    .shadow(color: .black,radius: 8)
                                    .foregroundColor(.gray)
                                    .padding(.leading)
                                    .padding(.top, -5)
                                Spacer()
                            }
                        }.listRowBackground(Color(.systemGray6))
                        .frame(width: 290)
                        .padding()
                        .border(Color(.systemGray4))

It’s not immediately obvious what the problem is. Maybe post the entire view code so that I can see the entire context of the View.