2016-05-10 8 views
1

私はSwiftでチャットiOSアプリをやっています。 ChatLogControllerでは、チャット画面に2つのバブル画像を追加しました。青いバブル画像が表示されますが、グレーのバブルは表示できません。私はxcassetsファイルに2つの画像を追加したと確信しています。灰色のバブル画像を表示できないのはなぜですか?

static let grayBubbleImage = UIImage(named:"bubble_gray")!.resizableImageWithCapInsets(UIEdgeInsetsMake(22,26,22,26)).imageWithRenderingMode(.AlwaysTemplate) 
static let blueBubbleImage = UIImage(named:"bubble_blue")!.resizableImageWithCapInsets(UIEdgeInsetsMake(22,26,22,26)).imageWithRenderingMode(.AlwaysTemplate) 

let bubbleImageView:UIImageView = 
{ 
    let imageView = UIImageView() 
    imageView.image = ChatLogMessageCell.grayBubbleImage 
    imageView.tintColor = UIColor(white: 0.90, alpha: 1) 
    return imageView 
}() 
if message.isSender!.boolValue 
    { 
     cell.messageTextView.frame = CGRectMake(48 + 8, 0, estimatedFrame.width + 16, estimatedFrame.height + 20) 
     cell.textBubbleView.frame = CGRectMake(48 - 10, -4, estimatedFrame.width + 16 + 8 + 16, estimatedFrame.height + 20 + 6) 
     cell.profileImageView.hidden = false 
     // cell.textBubbleView.backgroundColor = UIColor(white: 0.95, alpha: 1) 
     cell.bubbleImageView.image = ChatLogMessageCell.grayBubbleImage 
     cell.bubbleImageView.tintColor = UIColor(white: 0.95, alpha: 1) 
     cell.messageTextView.textColor = UIColor.blackColor() 

} 

else 
    { 
     cell.messageTextView.frame = CGRectMake(view.frame.width - estimatedFrame.width - 16 - 16,0, estimatedFrame.width + 16, estimatedFrame.height+20) 
     cell.textBubbleView.frame = CGRectMake(view.frame.width - estimatedFrame.width - 16 - 16 - 8, 0, estimatedFrame.width + 16 + 8, estimatedFrame.height+20) 
     cell.profileImageView.hidden = true 
     // cell.textBubbleView.backgroundColor = UIColor(red: 0, green: 137/255, blue: 249/255, alpha: 1) 
     cell.bubbleImageView.image = ChatLogMessageCell.blueBubbleImage 
     cell.bubbleImageView.tintColor = UIColor(red: 0, green: 137/255, blue: 249/255, alpha: 1) 
     cell.messageTextView.textColor = UIColor.whiteColor() 
     } 

ありがとうございます。

simulator image

+1

背景色は灰色の泡の色と同じですか?それらの両方をblurBubbleImageで置き、実際にその上にイメージビューがあることを確認してください。 – andykkt

+0

Bigありがとう、私はtextbubbleの表示色をブロックするのを忘れてしまった。 – Magenta

答えて

1

あなたは、画像のレンダリングモードを使用している、あなたのイメージがpngで、その後、あなたはImageViewの色合いのカラーを設定し、それはそのPNG画像の色を変更した場合そうalways templateです。だから、イメージビューに灰色の色合いの色を与えてイメージが灰色になり、そのイメージビューの背景色がグレーであれば、それを区別することはできません。

これは役に立ちます。

+0

大変ありがとうございます。灰色の背景色を消すのを忘れてしまった。 – Magenta

+0

上記のヘルプが必要です –

+0

@DilipTiwari:はい! – Lion

関連する問題