0

cellTopLabel の角と背景色を丸くしたいので、次のコードを使用しました。

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let cell = super.collectionView(collectionView, cellForItemAtIndexPath: indexPath) as! JSQMessagesCollectionViewCell

    cell.cellTopLabel?.backgroundColor = UIColor.whiteColor()
    cell.cellTopLabel?.layer.cornerRadius = 5
    cell.cellTopLabel?.bounds = CGRect(x: 0, y: 0, width: cell.cellTopLabel!.bounds.width/4, height: 20)

    return cell
}

しかし、私はこの結果を得ます:

ここに画像の説明を入力

cellTopLabel が画面全体の幅を取得するのではなく、必要な幅だけを取得したいのですが、どうすれば修正できますか?

4

1 に答える 1