2016-06-22 58 views
0

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

的documentatiojn位于实现:http://cocoadocs.org/docsets/JSQMessagesViewController/7.3.3/Classes/JSQMessagesAvatarImageFactory.html#//api/name/avatarImageWithUserInitials:backgroundColor:textColor:font:diameter

目前,似乎没有要落实在迅速此功能的方法。

如何将此功能添加到我的swift应用程序中?

回答

0

你可以在这里查看完整的实现。 https://github.com/jessesquires/JSQMessagesViewController/pull/1606

它很快就会成为Swift Example项目的一部分。

但基本的破败是你需要做一个可以这样做的头像对象。

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)) 

抱歉,这过了这么久。

+0

示例项目现在是主项目的一部分。 –