From cd9a48d4b5fc1d1f777d164962d2df75603bd14a Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 22 Apr 2019 11:49:22 -0500 Subject: [PATCH] Prevent auto layout from messing with our labels even though we told it not to. --- NetNewsWire.xcodeproj/project.pbxproj | 4 ++++ iOS/Extensions/NonIntrinsicLabel.swift | 18 ++++++++++++++++++ iOS/Master/Cell/MasterTableViewCell.swift | 2 +- .../Cell/MasterTimelineTableViewCell.swift | 4 ++-- 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 iOS/Extensions/NonIntrinsicLabel.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 7591fcb9a..f058d5c6d 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 512E09352268B25900BDCFDD /* UISplitViewController-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 512E092B2268B25500BDCFDD /* UISplitViewController-Extensions.swift */; }; 512E094D2268B8AB00BDCFDD /* DeleteCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C9C1FAE83C600ECDEDB /* DeleteCommand.swift */; }; 517D9075226639F500323654 /* AddAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 517D906B2266392900323654 /* AddAccountViewController.swift */; }; + 5183CCD0226E1E880010922C /* NonIntrinsicLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */; }; 519B8D332143397200FA689C /* SharingServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519B8D322143397200FA689C /* SharingServiceDelegate.swift */; }; 51C451A9226377C200C03939 /* ArticlesDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8407167F2262A61100344432 /* ArticlesDatabase.framework */; }; 51C451AA226377C200C03939 /* ArticlesDatabase.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8407167F2262A61100344432 /* ArticlesDatabase.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -609,6 +610,7 @@ 512E08F722688F7C00BDCFDD /* MasterTableViewSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTableViewSectionHeader.swift; sourceTree = ""; }; 512E092B2268B25500BDCFDD /* UISplitViewController-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISplitViewController-Extensions.swift"; sourceTree = ""; }; 517D906B2266392900323654 /* AddAccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountViewController.swift; sourceTree = ""; }; + 5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonIntrinsicLabel.swift; sourceTree = ""; }; 519B8D322143397200FA689C /* SharingServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingServiceDelegate.swift; sourceTree = ""; }; 51C4524E226506F400C03939 /* UIStoryboard-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIStoryboard-Extensions.swift"; sourceTree = ""; }; 51C4524F226506F400C03939 /* UIImage-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage-Extensions.swift"; sourceTree = ""; }; @@ -904,6 +906,7 @@ 51C45245226506C800C03939 /* Extensions */ = { isa = PBXGroup; children = ( + 5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */, 51C45250226506F400C03939 /* String-Extensions.swift */, 51C4524F226506F400C03939 /* UIImage-Extensions.swift */, 51C4524E226506F400C03939 /* UIStoryboard-Extensions.swift */, @@ -2185,6 +2188,7 @@ 51C4529B22650A1000C03939 /* FaviconDownloader.swift in Sources */, 512E09012268907400BDCFDD /* MasterTableViewSectionHeader.swift in Sources */, 51C45268226508F600C03939 /* MasterUnreadCountView.swift in Sources */, + 5183CCD0226E1E880010922C /* NonIntrinsicLabel.swift in Sources */, 51C452B1226510E600C03939 /* InitialFeedDownloader.swift in Sources */, 51C4529F22650A1900C03939 /* AuthorAvatarDownloader.swift in Sources */, 51C452A322650A1E00C03939 /* HTMLMetadataDownloader.swift in Sources */, diff --git a/iOS/Extensions/NonIntrinsicLabel.swift b/iOS/Extensions/NonIntrinsicLabel.swift new file mode 100644 index 000000000..67904fa44 --- /dev/null +++ b/iOS/Extensions/NonIntrinsicLabel.swift @@ -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) + } + +} diff --git a/iOS/Master/Cell/MasterTableViewCell.swift b/iOS/Master/Cell/MasterTableViewCell.swift index 97fd9ad06..e20714e73 100644 --- a/iOS/Master/Cell/MasterTableViewCell.swift +++ b/iOS/Master/Cell/MasterTableViewCell.swift @@ -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 diff --git a/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift b/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift index 6b823784d..b0acf2192 100644 --- a/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift +++ b/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift @@ -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