cs4alhaider/ProfilePlaceholderView
Add profile placeholder when there is no image π
Example Contacts app
| List of contacts | #1. | #2. | #3. | | --- | --- | --- | --- | | | | | |
Installation
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
Usage
import ProfilePlaceholderViewThen 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)
}
}
}
or, if you don't want to use any image and you just need a placeholder, then do this:
struct ContactRow: View {
let contact: Contact
var body: some View {
HStack {
ProfilePlaceholderView(name: contact.name)
.clipShape(Circle())
.frame(width: 60, height: 60)
Text(contact.name)
.font(.headline)
}
}
}Check the Example project for more details
License
This project is under the MIT license. See the LICENSE file for more info.
Package Metadata
Repository: cs4alhaider/ProfilePlaceholderView
Stars: 2
Forks: 0
Open issues: 0
Default branch: master
Primary language: swift
License: MIT
README: README.md