gpt4 book ai didi

objective-c - 在 Swift 中实现 avatarImageWithUserInitials

转载 作者:行者123 更新时间:2023-11-30 13:18:54 25 4
gpt4 key购买 nike

我需要从 JSQMessages 框架实现 avatarImageWithUserInitials 。然而它似乎只在 Objective-C 中实现

文档位于:http://cocoadocs.org/docsets/JSQMessagesViewController/7.3.3/Classes/JSQMessagesAvatarImageFactory.html#//api/name/avatarImageWithUserInitials:backgroundColor:textColor:font:diameter :

目前看来还没有办法在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com