JNAvatarWithInitials
JNAvatarWithInitials 用于使用 Web URL 或 UIImage 对象显示单个头像图像,并可选择显示首字母。
屏幕截图
要求
- iOS 9.0+ / macOS 10.10+
- Xcode 9.0+
- Swift 4+
安装
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要将JNAvatarWithInitials集成到您的Xcode项目中并使用CocoaPods,请在您的Podfile
中指定它。
use_frameworks!
target '<Your Target Name>' do
pod 'JNAvatarWithInitials'
end
然后,运行以下命令
$ pod install
用法
在Interface Builder中添加JNAvatarWithInitials
-
放入一些UIView并更改类为“JNAvatarWithInitials”
-
在视图控制器中添加对它的引用。
-
更改属性
- initialsFont : 用于字母缩写的字体。
- initialTextColor : 用于字母缩写的文本颜色。
- initialLabelInset : 应用于字母缩写标签的内边距。
- 调用设置方法
使用图片URL设置视图
func setup(imageUrl : String , placeHolderImage : UIImage , fullName : String , showInitails)
参数
- imageUrl : 用于加载图片的图片URL。
- placeHolderImage : 失败时使用的占位符图片。
- fullName : 用于字母缩写的全名。
- showInitails : 标志,表示是否应该显示字母缩写。
使用UIImage设置视图
func setup(image : UIImage? , placeHolderImage : UIImage , fullName : String , showInitails)
参数
- image : 要设置的UIImage对象。
- placeHolderImage : 如果UIImage对象为空时使用的占位符图片。
- fullName : 用于字母缩写的全名。
- showInitails : 标志,表示是否应该显示字母缩写。
- 获取器方法
获取Image View
func getImageView() -> UIImageView
作者
Jayel Zaghmoutt & Mohammad Nabulsi
许可
JNAvatarWithInitials 是基于 MIT 许可证提供的。更多详细信息请参阅 LICENSE 文件。