Another point. Why do you specify a zero height ?
let targetSize = CGSize(width: layoutAttributes.frame.width, height: 0)
It seems your cell height should be at least 40 ; so why not specify 40 ?
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: