fix: some label trimmed under zoomed display mode issue

This commit is contained in:
CMK 2021-08-04 16:24:19 +08:00
parent 9a8653f39c
commit 7806816213
7 changed files with 43 additions and 6 deletions

View File

@ -78,12 +78,14 @@ extension NotificationSection {
}
let createAt = notification.createAt
let actionText = notification.notificationType.actionText
cell.actionLabel.text = actionText + " · " + createAt.timeAgoSinceNow
cell.actionLabel.text = actionText
cell.timestampLabel.text = createAt.timeAgoSinceNow
AppContext.shared.timestampUpdatePublisher
.receive(on: DispatchQueue.main)
.sink { [weak cell] _ in
guard let cell = cell else { return }
cell.actionLabel.text = actionText + " · " + createAt.timeAgoSinceNow
cell.actionLabel.text = actionText
cell.timestampLabel.text = createAt.timeAgoSinceNow
}
.store(in: &cell.disposeBag)

View File

@ -67,3 +67,9 @@ extension UIView {
return self
}
}
extension UIView {
static var isZoomedMode: Bool {
return UIScreen.main.scale != UIScreen.main.nativeScale
}
}

View File

@ -56,6 +56,19 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
label.lineBreakMode = .byTruncatingTail
return label
}()
let dotLabel: UILabel = {
let label = UILabel()
label.textColor = Asset.Colors.Label.secondary.color
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .regular), maximumPointSize: 20)
label.text = "·"
return label
}()
let timestampLabel: UILabel = {
let label = UILabel()
label.textColor = Asset.Colors.Label.secondary.color
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .regular), maximumPointSize: 20)
return label
}()
let nameLabel = MetaLabel(style: .notificationName)
@ -170,12 +183,21 @@ extension NotificationStatusTableViewCell {
actionStackView.addArrangedSubview(nameLabel)
actionStackView.addArrangedSubview(actionLabel)
nameLabel.setContentHuggingPriority(.required - 1, for: .horizontal)
actionStackView.addArrangedSubview(dotLabel)
actionStackView.addArrangedSubview(timestampLabel)
let timestampPaddingView = UIView()
actionStackView.addArrangedSubview(timestampPaddingView)
nameLabel.setContentHuggingPriority(.required - 3, for: .horizontal)
nameLabel.setContentHuggingPriority(.required - 1, for: .vertical)
nameLabel.setContentCompressionResistancePriority(.required - 1, for: .horizontal)
nameLabel.setContentCompressionResistancePriority(.required - 3, for: .horizontal)
nameLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical)
actionLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
dotLabel.setContentHuggingPriority(.required - 2, for: .horizontal)
dotLabel.setContentCompressionResistancePriority(.required - 2, for: .horizontal)
timestampLabel.setContentHuggingPriority(.required - 1, for: .horizontal)
timestampLabel.setContentCompressionResistancePriority(.required - 1, for: .horizontal)
timestampPaddingView.setContentHuggingPriority(.defaultLow, for: .horizontal)
// follow request
contentStackView.addArrangedSubview(buttonStackView)
buttonStackView.addArrangedSubview(acceptButton)

View File

@ -29,6 +29,10 @@ final class ProfileStatusDashboardMeterView: UIView {
label.textColor = Asset.Colors.Label.primary.color
label.text = L10n.Scene.Profile.Dashboard.posts
label.textAlignment = .center
if UIView.isZoomedMode {
label.adjustsFontSizeToFitWidth = true
label.minimumScaleFactor = 0.8
}
return label
}()

View File

@ -47,7 +47,7 @@ extension ProfileStatusDashboardView {
containerStackView.heightAnchor.constraint(equalToConstant: 44).priority(.defaultHigh),
])
let spacing: CGFloat = 16
let spacing: CGFloat = UIView.isZoomedMode ? 4 : 16
containerStackView.spacing = spacing
containerStackView.axis = .horizontal
containerStackView.distribution = .fillEqually

View File

@ -29,6 +29,8 @@ class SearchRecommendCollectionHeader: UIView {
let button = HighlightDimmableButton(type: .custom)
button.setTitleColor(Asset.Colors.brandBlue.color, for: .normal)
button.setTitle(L10n.Scene.Search.Recommend.buttonText, for: .normal)
button.titleLabel?.adjustsFontSizeToFitWidth = true
button.titleLabel?.minimumScaleFactor = 0.8
return button
}()

View File

@ -44,6 +44,7 @@ class SettingsToggleTableViewCell: UITableViewCell {
private func setupUI() {
selectionStyle = .none
accessoryView = switchButton
textLabel?.numberOfLines = 0
switchButton.addTarget(self, action: #selector(switchValueDidChange(sender:)), for: .valueChanged)
}