Introduction
RFGravatarImageView is a lightweight Swift library that allows you to easily display Gravatar profile images in your iOS app. Gravatar is a service that associates an image with an email address, so users can have a consistent profile picture across multiple websites.
Requirements
- iOS 9.0+
- Xcode 11.0+
- Swift 5+
Installation
To integrate RFGravatarImageView into your project, you can use CocoaPods, Carthage, or manually import the framework.
CocoaPods
Add the following line to your Podfile:
pod 'RFGravatarImageView'
Then run the following command:
$ pod install
Carthage
Add the following line to your Cartfile:
github "sehehe/RFGravatarImageView"
Then run the following command:
$ carthage update
Usage
Example
Here’s an example of how to use RFGravatarImageView:
let gravatarImageView = RFGravatarImageView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
gravatarImageView.email = "example@email.com"
gravatarImageView.placeholderImage = UIImage(named: "placeholder")
view.addSubview(gravatarImageView)
Configuration
RFGravatarImageView provides several properties and methods for customizing and configuring the image view:
- email: The email associated with the Gravatar profile. (required)
- placeholderImage: The image to display while the Gravatar is loading. (optional)
- gravatarURLBuilder: A closure that allows you to customize the URL used to fetch the Gravatar image. (optional)
- reloadImage(): Reloads the Gravatar image.
- cancelLoading(): Cancels any ongoing image loading operations.
Contribution
Contributions to RFGravatarImageView are welcome. Please follow the contribution guidelines when making pull requests.
License
RFGravatarImageView is available under the MIT license. See the LICENSE file for more info.