如何根据textview高度动态更改collectionviewcell。 as you see there is extra space in the second textview
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let statusText = statussText[indexPath.item]
let rect = NSString(string: statusText).boundingRectWithSize(CGSizeMake(293, 155), options: NSStringDrawingOptions.UsesFontLeading.union(NSStringDrawingOptions.UsesLineFragmentOrigin), attributes: [NSFontAttributeName: UIFont.systemFontOfSize(14)], context: nil)
let knownHeight: CGFloat = 113//44 + 4 + 4 + 200 + 8 + 24 + 8 + 44
return CGSizeMake(293, rect.height + knownHeight + 110)//74 + 67 + 50)//+ knownHeight + 100)
}
这是我的代码。
更新
我已经用tableview解决了这个问题。它比collectionview更不易定制。