2
我正在寻找一种方法来更改气泡中的消息文本颜色,我发现在ObjC示例中很容易,试图在swift中做同样的事情,但失败了,任何解决方案?更改聊天气泡中的textview颜色
这里是ObjC代码
- (UICollectionViewCell *)collectionView:(JSQMessagesCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
/**
* Override point for customizing cells
*/
JSQMessagesCollectionViewCell *cell = (JSQMessagesCollectionViewCell *)[super collectionView:collectionView cellForItemAtIndexPath:indexPath];
/**
* Configure almost *anything* on the cell
*
* Text colors, label text, label colors, etc.
*
*
* DO NOT set `cell.textView.font` !
* Instead, you need to set `self.collectionView.collectionViewLayout.messageBubbleFont` to the font you want in `viewDidLoad`
*
*
* DO NOT manipulate cell layout information!
* Instead, override the properties you want on `self.collectionView.collectionViewLayout` from `viewDidLoad`
*/
JSQMessage *msg = [self.demoData.messages objectAtIndex:indexPath.item];
if (!msg.isMediaMessage) {
if ([msg.senderId isEqualToString:self.senderId]) {
cell.textView.textColor = [UIColor blackColor];
}
else {
cell.textView.textColor = [UIColor whiteColor];
}
cell.textView.linkTextAttributes = @{ NSForegroundColorAttributeName : cell.textView.textColor,
NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle | NSUnderlinePatternSolid) };
}
cell.accessoryButton.hidden = ![self shouldShowAccessoryButtonForMessage:msg];
return cell;
}**
它覆盖编辑以collectionview
要求后,它会再次
后,你已经尝试和没有工作的SWIFT代码。 –
同样的代码翻译成swift,它不会工作 – Abdoelrhman
@AbdoelrhmanMohamed你需要告诉我们你有什么尝试和什么不工作,告诉我们它的截图。 –