Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
fixes gracefully changing cell height constraint via string+struts
Browse files Browse the repository at this point in the history
  • Loading branch information
icanzilb committed Aug 7, 2017
1 parent 71c3d53 commit 1b60e75
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions RealmContent/Core/View/ImageContentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,15 @@ public class ImageContentCell: UITableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

let marginGuide = contentView.layoutMarginsGuide

img.translatesAutoresizingMaskIntoConstraints = true
img.contentMode = .scaleAspectFit
img.frame = contentView.bounds.insetBy(dx: layoutMargins.left, dy: layoutMargins.top)
img.autoresizingMask = [.flexibleWidth, .flexibleHeight]

// configure titleLabel
contentView.addSubview(img)
img.translatesAutoresizingMaskIntoConstraints = false
img.leadingAnchor.constraint(equalTo: marginGuide.leadingAnchor).isActive = true
img.topAnchor.constraint(equalTo: marginGuide.topAnchor).isActive = true
img.trailingAnchor.constraint(equalTo: marginGuide.trailingAnchor).isActive = true
img.bottomAnchor.constraint(equalTo: marginGuide.bottomAnchor).isActive = true
heightConstraint = img.heightAnchor.constraint(equalToConstant: 20)

heightConstraint = contentView.heightAnchor.constraint(equalToConstant: 20)
heightConstraint.priority = 500
heightConstraint.isActive = true
}

Expand Down

0 comments on commit 1b60e75

Please sign in to comment.