我需要从 JSQMessages 框架实现 avatarImageWithUserInitials
。然而它似乎只在 Objective-C 中实现
目前看来还没有办法在 swift 中快速实现这个功能。
如何将此功能添加到我的 swift 应用程序中?
最佳答案
您可以在此处查看完整的实现。 https://github.com/jessesquires/JSQMessagesViewController/pull/1606
它将很快成为 Swift 示例项目的一部分。
但是基本的要点是你需要制作一个头像对象,可以像这样完成。
let AvatarLeonard = JSQMessagesAvatarImageFactory.avatarImageWithUserInitials("DL", backgroundColor: UIColor.jsq_messageBubbleGreenColor(), textColor: UIColor.whiteColor(), font: UIFont.systemFontOfSize(12), diameter: UInt(kJSQMessagesCollectionViewAvatarSizeDefault))
还有这个选项:
// Create avatar with Placeholder Image
let AvatarJobs = JSQMessagesAvatarImageFactory.avatarImageWithPlaceholder(UIImage(named: "Jobs"), diameter: UInt(kJSQMessagesCollectionViewAvatarSizeDefault))
抱歉,这花了这么长时间。 🖖🏽
关于objective-c - 在 Swift 中实现 avatarImageWithUserInitials,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37957021/