Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Improved formatting to fit the screen
Source Link
Şafak Gezer
  • 4k
  • 3
  • 51
  • 54
ZStack{ Button(action: {}){ Image(systemName: "heart.fill") .resizable() .frame(width: 40, height: 40) .padding(25) .foregroundColor(Color(red: 52/255, green: 57/255, blue: 133/255)) .overlay( RoundedRectangle(cornerRadius: 15) .stroke(Color(red: 236/255, green: 234/255, blue: 235/255),  lineWidth: 4) .shadow(color: Color(red: 192/255, green: 189/255, blue: 191/255),  radius: 3, x: 5, y: 5) .clipShape( RoundedRectangle(cornerRadius: 15) ) .shadow(color: Color.white, radius: 2, x: -2, y: -2) .clipShape( RoundedRectangle(cornerRadius: 15) ) ) .background(Color(red: 236/255, green: 234/255, blue: 235/255)) .cornerRadius(20) } 
ZStack{ Button(action: {}){ Image(systemName: "heart.fill") .resizable() .frame(width: 40, height: 40) .padding(25) .foregroundColor(Color(red: 52/255, green: 57/255, blue: 133/255)) .overlay( RoundedRectangle(cornerRadius: 15) .stroke(Color(red: 236/255, green: 234/255, blue: 235/255), lineWidth: 4) .shadow(color: Color(red: 192/255, green: 189/255, blue: 191/255), radius: 3, x: 5, y: 5) .clipShape( RoundedRectangle(cornerRadius: 15) ) .shadow(color: Color.white, radius: 2, x: -2, y: -2) .clipShape( RoundedRectangle(cornerRadius: 15) ) ) .background(Color(red: 236/255, green: 234/255, blue: 235/255)) .cornerRadius(20) } 
ZStack{ Button(action: {}){ Image(systemName: "heart.fill") .resizable() .frame(width: 40, height: 40) .padding(25) .foregroundColor(Color(red: 52/255, green: 57/255, blue: 133/255)) .overlay( RoundedRectangle(cornerRadius: 15) .stroke(Color(red: 236/255, green: 234/255, blue: 235/255),  lineWidth: 4) .shadow(color: Color(red: 192/255, green: 189/255, blue: 191/255),  radius: 3, x: 5, y: 5) .clipShape( RoundedRectangle(cornerRadius: 15) ) .shadow(color: Color.white, radius: 2, x: -2, y: -2) .clipShape( RoundedRectangle(cornerRadius: 15) ) ) .background(Color(red: 236/255, green: 234/255, blue: 235/255)) .cornerRadius(20) } 
added 326 characters in body
Source Link
Carles Mitjans
  • 4.9k
  • 3
  • 22
  • 39
ZStack{ Button(action: {}){ Image(systemName: "heart.fill") .resizable() .frame(width: 40, height: 40) .padding(25) .foregroundColor(Color(red: 52/255, green: 57/255, blue: 133/255)) .overlay( RoundedRectangle(cornerRadius: 15) .stroke(Color(red: 236/255, green: 234/255, blue: 235/255), lineWidth: 4) .shadow(color: Color(red: 192/255, green: 189/255, blue: 191/255), radius: 3, x: 5, y: 5) .clipShape( RoundedRectangle(cornerRadius: 15) ) .shadow(color: Color.white, radius: 2, x: -2, y: -2) .clipShape( RoundedRectangle(cornerRadius: 15) ) ) .background(Color(red: 236/255, green: 234/255, blue: 235/255)) .cornerRadius(20) } 
ZStack{ Button(action: {}){ Image(systemName: "heart.fill") .resizable() .frame(width: 40, height: 40) .padding(25) .foregroundColor(Color(red: 52/255, green: 57/255, blue: 133/255)) .overlay(RoundedRectangle(cornerRadius: 15).stroke(Color(red: 236/255, green: 234/255, blue: 235/255), lineWidth: 4).shadow(color: Color(red: 192/255, green: 189/255, blue: 191/255), radius: 3, x: 5, y: 5).clipShape(RoundedRectangle(cornerRadius: 15)).shadow(color: Color.white, radius: 2, x: -2, y: -2).clipShape(RoundedRectangle(cornerRadius: 15))) .background(Color(red: 236/255, green: 234/255, blue: 235/255)) .cornerRadius(20) } 
ZStack{ Button(action: {}){ Image(systemName: "heart.fill") .resizable() .frame(width: 40, height: 40) .padding(25) .foregroundColor(Color(red: 52/255, green: 57/255, blue: 133/255)) .overlay( RoundedRectangle(cornerRadius: 15) .stroke(Color(red: 236/255, green: 234/255, blue: 235/255), lineWidth: 4) .shadow(color: Color(red: 192/255, green: 189/255, blue: 191/255), radius: 3, x: 5, y: 5) .clipShape( RoundedRectangle(cornerRadius: 15) ) .shadow(color: Color.white, radius: 2, x: -2, y: -2) .clipShape( RoundedRectangle(cornerRadius: 15) ) ) .background(Color(red: 236/255, green: 234/255, blue: 235/255)) .cornerRadius(20) } 
Source Link
A.Cal
  • 306
  • 3
  • 10

This is what I did to create an inner shadow like the one in the picture. I created it in another swiftui file and just called in in my main content view but you can display it however you'd like.

I created a Button in a ZStack only because I first recreated it with a rounded rectangle but I think this would would in a HStack or VStack as well just haven't tried them. To create the inner shadow I created an overlay and clipped the shadows to the shape.

ZStack{ Button(action: {}){ Image(systemName: "heart.fill") .resizable() .frame(width: 40, height: 40) .padding(25) .foregroundColor(Color(red: 52/255, green: 57/255, blue: 133/255)) .overlay(RoundedRectangle(cornerRadius: 15).stroke(Color(red: 236/255, green: 234/255, blue: 235/255), lineWidth: 4).shadow(color: Color(red: 192/255, green: 189/255, blue: 191/255), radius: 3, x: 5, y: 5).clipShape(RoundedRectangle(cornerRadius: 15)).shadow(color: Color.white, radius: 2, x: -2, y: -2).clipShape(RoundedRectangle(cornerRadius: 15))) .background(Color(red: 236/255, green: 234/255, blue: 235/255)) .cornerRadius(20) } 

The end result looked like this: enter image description here

You can play around with the colors and the shadows to get exactly what you want but hopefully this helps!