Prevent auto layout from messing with our labels even though we told it not to.

This commit is contained in:
Maurice Parker
2019-04-22 11:49:22 -05:00
parent 5b75add585
commit cd9a48d4b5
4 changed files with 25 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
//
// MasterTimelineLabel.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 4/22/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
class NonIntrinsicLabel: UILabel {
// Prevent autolayout from messing around with our frame settings
override var intrinsicContentSize: CGSize {
return CGSize(width: UIView.noIntrinsicMetric, height: UIView.noIntrinsicMetric)
}
}

View File

@@ -85,7 +85,7 @@ class MasterTableViewCell : UITableViewCell {
}
private let titleView: UILabel = {
let label = UILabel()
let label = NonIntrinsicLabel()
label.numberOfLines = 1
label.lineBreakMode = .byTruncatingTail
label.allowsDefaultTighteningForTruncation = false

View File

@@ -74,14 +74,14 @@ class MasterTimelineTableViewCell: UITableViewCell {
private extension MasterTimelineTableViewCell {
static func singleLineUILabel() -> UILabel {
let label = UILabel()
let label = NonIntrinsicLabel()
label.lineBreakMode = .byTruncatingTail
label.allowsDefaultTighteningForTruncation = false
return label
}
static func multiLineUILabel() -> UILabel {
let label = UILabel()
let label = NonIntrinsicLabel()
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
label.allowsDefaultTighteningForTruncation = false