目录
目录README.md

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 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)
        }
    }
}

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

Author

Abdullah Alhaider, cs.alhaider@gmail.com

License

This project is under the MIT license. See the LICENSE file for more info.

关于
1.1 MB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号