Add profile placeholder when there is no image 😎
List of contacts | #1. | #2. | #3. |
---|---|---|---|
It requires iOS 13 and Xcode 11!
In Xcode go to File -> Swift Packages -> Add Package Dependency
and paste in the repo's url: https://github.com/cs4alhaider/ProfilePlaceholderView
import ProfilePlaceholderView
Then add .withProfilePlaceholderView( ... )
under Image
like:
struct ContactRow: View {
let contact: Contact
var body: some View {
HStack {
Image(contact.imageString ?? "")
.resizable()
.withProfilePlaceholderView(name: contact.name) // HERE YOU CAN PASS MANY THINGS ALSO
.clipShape(Circle())
.frame(width: 60, height: 60)
Text(contact.name)
.font(.headline)
}
}
}
Check the Example project for more details
Abdullah Alhaider, cs.alhaider@gmail.com
This project is under the MIT license. See the LICENSE file for more info.