JNHorizontalGroupAvatarCollectionView
JNHorizontalGroupAvatarCollectionView用于显示包含头像图像的集合,可以选择显示首字母,它会在手机屏幕可以显示的范围内进行水平滚动,以查看更多。
截图
示例
要运行示例项目,请克隆仓库,然后首先从示例目录运行 pod install
。
要求
- iOS 9.0+ / macOS 10.10+
- Xcode 9.0+
- Swift 4+
安装
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用 CocoaPods 将 JNHorizontalGroupAvatarCollectionView 集成到您的 Xcode 项目中,在您的 Podfile
中指定它
use_frameworks!
target '<Your Target Name>' do
pod 'JNHorizontalGroupAvatarCollectionView'
end
然后,运行以下命令
$ pod install
使用方法
在 Interface Builder 中添加 JNHorizontalGroupAvatarCollectionView
-
放置一些 UIView 并将类更改为 "JNHorizontalGroupAvatarCollectionView"
-
在视图控制器中添加对它的引用。
-
在您的视图控制器中实现 JNHorizontalGroupAvatarCollectionViewDelegate 并设置代理如下
/**
Number of items
- Returns: The number of items in collection view
*/
func horizontalGroupAvatarCollectionViewNumberOfItems() -> Int
/**
Data for item at index
- Parameter index: The item index
- Returns: The data for the item
*/
func horizontalGroupAvatarCollectionView(dataForItemAt index: Int) -> [JNGroupAvatar]
/**
Did clear data
*/
func horizontalGroupAvatarCollectionViewDidClearData()
- 按照以下方式实现您的 '如用户' 类的 JNGroupAvatar
/**
Get display name which will be used for the initials.
- Returns: The display name for the avatar
*/
func getGroupAvatarDisplayName() -> String
/**
Get Avatar image url which will be used as avatar url
- Returns: The image url
*/
func getGroupAvatarImageUrl() -> String
/**
Get Avatar image which will be used as avatar
- Returns: The image
*/
func getGroupAvatarImage() -> UIImage
- cellPadding : 完成头像图片之间的填充。
- avatars : 将用于绘制的 JNGroupAvatar 数组。
- imagesLayoutDirection : 要使用的图像布局方向(从右到左或从左到右)。
- avatarsMargin : 头像之间的边距(分隔符的宽度和高度)。
- separatorColor : 要使用的分隔符颜色。
- placeHolderImage : 如果图片加载失败,使用的占位符。
- showInitails : 如果图片加载失败或未失败时显示首字母,如果是 false 则设置占位符图片。
- initialsFont : 使用首字母的字体。
- initialTextColor : 使用首字母的文本颜色。
此库依赖于 JNGroupAvatarImageView,更多信息请查看。
作者
Jayel Zaghmoutt, Mohammad Nabulsi 及 Ali Hamad
许可证
JNHorizontalGroupAvatarCollectionView 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。