Home > front end >  Swift: Encapsulated Layout Height always .333 larger than view
Swift: Encapsulated Layout Height always .333 larger than view

Time:04-02

I am building a TableView filled with a variable number of cells. One type of those cells should have a fixed height of 69.0, but xcode keeps setting its encapsulated layout height .333 larger than what I set the height to, meaning it breaks the constraints because the encapsulated layout height is 69.333. If I change my Cell's size to 70 for example, the constraint is set to 70.333. I don't understand what causes this.

Here is the Cell:

class AnnotationCell: UITableViewCell {

//Set identifier to be able to call it later on
static let identifier = "AnnotationCell"

var annotation: Annotation!

//MARK: - Configure
public func configure(annotation: Annotation) {
    self.annotation = annotation
}
//MARK: - Cell Style
//Add all subviews in here
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
    commonInit()
}

required init?(coder: NSCoder) {
    super.init(coder: coder)
    commonInit()
}

func commonInit() {
    //Customize Cell
    contentView.backgroundColor = colors.darkGray
    contentView.layer.borderWidth = 0
    
    //Favorite
    let favoriteView = UIView()
    favoriteView.backgroundColor = colors.gray
    favoriteView.addBorders(edges: [.top], color: colors.lightGray, width: 1)
    favoriteView.translatesAutoresizingMaskIntoConstraints = false
    
    let favIcon = UIImageView()
    let myEmoji = "           
  • Related