UIImageView Extensions
Set of helper methods defined on UIImageView to simplify displaying a user's image.
Last updated
Set of helper methods defined on UIImageView to simplify displaying a user's image.
Last updated
For most cases, you will likely have one or more UIImageView
s defined for a view controller where you will want to display a user's profile pic and/or cover photo, such as on a profile screen. The methods in this extension simplify that by taking an image id, making a request for that image, and if successful, set an image view's image
property to that image.
Request an image by its id and if successful, set as the image view's image
property.
Request a user's profile pic by its id. If the request fails, sets the image
property to a default image; otherwise, sets the image
property to the user's profile pic.
Request a user's cover photo by its id. If the request fails, sets the image
property to a default image; otherwise, sets the image
property to the user's cover photo.
Parameter
Type
Description
forImageId
String?
String representing an image's id.
completion
(Error?) -> Void
The closure invoked when the request finishes.
error
Error?
The error returned for an unsuccessful request.
Parameter
Type
Description
forImageId
String?
The id of a user's profile pic.
completion
(Error?) -> Void
The closure invoked when the request finishes.
error
Error?
The error returned for an unsuccessful request.
Parameter
Type
Description
forImageId
String?
The id of a user's cover photo.
completion
(Error?) -> Void
The closure invoked when the request finishes.
error
Error?
The error returned for an unsuccessful request.