JNGroupAvatarImageView is used to show group or single avatar image with the option to show initials, it can show 4 images at most.
- iOS 9.0+ / macOS 10.10+
- Xcode 9.0+
- Swift 4+
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate JNGroupAvatarImageView into your Xcode project using CocoaPods, specify it in your Podfile
:
use_frameworks!
target '<Your Target Name>' do
pod 'JNGroupAvatarImageView'
end
Then, run the following command:
$ pod install
-
Put some UIView and change the class to "JNGroupAvatarImageView"
-
Add refrence for it in the view controller.
-
Implement JNGroupAvatar In you class like the following:
class User : JNGroupAvatar {
/**
Get display name which will be used for the initials.
- Returns: The display name for the avatar
*/
func getGroupAvatarDisplayName() -> String {
return ""
}
/**
Get Avatar image url which will be used as avatar url
- Returns: The image url
*/
func getGroupAvatarImageUrl() -> String {
return ""
}
/**
Get Avatar image which will be used as avatar
- Returns: The image
*/
func getGroupAvatarImage() -> UIImage {
return UIImage()
}
}
- Call setup method with the following parameters:
func setup(avatars : [JNGroupAvatar] , imagesLayoutDirection : ImagesLayoutDirection , avatarsMargin : CGFloat , separatorColor : UIColor, placeHolderImage : UIImage! , showInitails : Bool , initialsFont : UIFont , initialTextColor : UIColor)
- avatars : Array fo JNGroupAvatar which will be used to draw .
- imagesLayoutDirection : The image layout direction to use (right to left or left to right).
- avatarsMargin : The margin between avatars (separator with or height).
- separatorColor : The separator color to use.
- placeHolderImage : The placeholder to use if the image failed to load.
- showInitails : Show initials if the image failed to load or not, if false then set placeholder image.
- initialsFont : The font to use for the initials.
- initialTextColor : The text color to use for the initials.
The libarary will automaticly adjust initials label insets if the view is circle.
Jayel Zaghmoutt & Mohammad Nabulsi
JNGroupAvatarImageView is available under the MIT license. See the LICENSE file for more info.