OGeek|极客世界-中国程序员成长平台

标题: ios - JSQMessagesViewController changedBubbleImage 不工作 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 16:58
标题: ios - JSQMessagesViewController changedBubbleImage 不工作

我尝试通过将自定义图像传递给 init 方法来更改 JSQMessagesViewController 的默认 MessagesBubbleImage,但它不起作用,这是代码

outgoingBubbleImageView = JSQMessagesBubbleImageFactory.init(bubbleImage: UIImage(named: "bubbleMine"), capInsets: UIEdgeInsetsZero).outgoingMessagesBubbleImageWithColor(UIColor.grayColor())



Best Answer-推荐答案


你好,我一直在研究你的问题,但我已经解决了 Objective C,所以我会将我的答案和翻译发布到 Swift

DemoModelData 初始化

JSQMessagesBubbleImageFactory *bubbleFactory = [[JSQMessagesBubbleImageFactory alloc] initWithBubbleImage:[UIImage imageNamed"bubbleMine"] capInsets:UIEdgeInsetsZero layoutDirection:UIUserInterfaceLayoutDirectionRightToLeft];

self.outgoingBubbleImageData = [bubbleFactory outgoingMessagesBubbleImageWithColor:[UIColor grayColor]];

快速翻译

let bubbleFactory = JSQMessagesBubbleImageFactory(bubbleImage: UIImage(named: "bubbleMine")!, capInsets: UIEdgeInsetsZero, layoutDirection: .RightToLeft)

self.outgoingBubbleImageData = bubbleFactory.outgoingMessagesBubbleImageWithColor(UIColor.grayColor())
self.incomingBubbleImageData = bubbleFactory.outgoingMessagesBubbleImageWithColor(UIColor.jsq_messageBubbleGreenColor())

请注意,您从中得到的是形状,而不是颜色

希望对你有帮助,对我来说没问题

关于ios - JSQMessagesViewController changedBubbleImage 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38335369/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4