summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ios/MullvadVPN/View controllers/Settings/SettingsCell.swift36
1 files changed, 15 insertions, 21 deletions
diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsCell.swift b/ios/MullvadVPN/View controllers/Settings/SettingsCell.swift
index b642549d5a..8157e300cc 100644
--- a/ios/MullvadVPN/View controllers/Settings/SettingsCell.swift
+++ b/ios/MullvadVPN/View controllers/Settings/SettingsCell.swift
@@ -79,30 +79,24 @@ class SettingsCell: UITableViewCell {
titleLabel.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
detailTitleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
- contentView.addSubview(titleLabel)
- contentView.addSubview(detailTitleLabel)
-
setLayoutMargins()
- NSLayoutConstraint.activate([
- titleLabel.leadingAnchor
- .constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor),
- titleLabel.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
- titleLabel.bottomAnchor
- .constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor),
-
- detailTitleLabel.leadingAnchor.constraint(
- greaterThanOrEqualToSystemSpacingAfter: titleLabel.trailingAnchor,
- multiplier: 1
- ),
+ contentView.addConstrainedSubviews([titleLabel, detailTitleLabel]) {
+ switch style {
+ case .subtitle:
+ titleLabel.pinEdgesToSuperviewMargins(.all().excluding(.bottom))
+ detailTitleLabel.pinEdgesToSuperviewMargins(.all().excluding(.top))
+ detailTitleLabel.topAnchor.constraint(equalToSystemSpacingBelow: titleLabel.bottomAnchor, multiplier: 1)
- detailTitleLabel.trailingAnchor
- .constraint(equalTo: contentView.layoutMarginsGuide.trailingAnchor),
- detailTitleLabel.topAnchor
- .constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
- detailTitleLabel.bottomAnchor
- .constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor),
- ])
+ default:
+ titleLabel.pinEdgesToSuperviewMargins(.all().excluding(.trailing))
+ detailTitleLabel.pinEdgesToSuperviewMargins(.all().excluding(.leading))
+ detailTitleLabel.leadingAnchor.constraint(
+ greaterThanOrEqualToSystemSpacingAfter: titleLabel.trailingAnchor,
+ multiplier: 1
+ )
+ }
+ }
}
required init?(coder: NSCoder) {