Skip to content

Commit

Permalink
fix: fix resetting rotation dial caused UI issue (#287)
Browse files Browse the repository at this point in the history
fix cropToolBar button display issue when using bigger dynamic fonts
  • Loading branch information
guoyingtao committed Mar 2, 2023
1 parent 47add3a commit f432e36
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
27 changes: 17 additions & 10 deletions Sources/Mantis/CropViewController/CropToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,24 +256,31 @@ extension CropToolbar {
button.titleLabel?.minimumScaleFactor = 0.5
button.translatesAutoresizingMaskIntoConstraints = false

let compressionPriority: Float

if let title = title {
button.setTitle(title, for: .normal)
button.setTitleColor(buttonColor, for: .normal)
button.accessibilityIdentifier = "\(title)"

// Set content compression resistance priority
compressionPriority = AutoLayoutPriorityType.high.rawValue + 2
} else {
// Set content compression resistance priority
compressionPriority = AutoLayoutPriorityType.high.rawValue + 1
}

// Set content hugging priority
let huggingPriority: Float = 250
button.setContentHuggingPriority(UILayoutPriority(rawValue: huggingPriority), for: .horizontal)
button.setContentHuggingPriority(UILayoutPriority(rawValue: huggingPriority), for: .vertical)

// Set content compression resistance priority
let compressionPriority = AutoLayoutPriorityType.high.rawValue + 1
button.setContentCompressionResistancePriority(UILayoutPriority(rawValue: compressionPriority), for: .horizontal)
button.setContentCompressionResistancePriority(UILayoutPriority(rawValue: compressionPriority), for: .vertical)

// Set width constraint
button.widthAnchor.constraint(greaterThanOrEqualToConstant: button.intrinsicContentSize.width).isActive = true

button.setContentCompressionResistancePriority(UILayoutPriority(rawValue: compressionPriority), for: .horizontal)
button.setContentCompressionResistancePriority(UILayoutPriority(rawValue: compressionPriority), for: .vertical)

if let title = title {
button.setTitle(title, for: .normal)
button.setTitleColor(buttonColor, for: .normal)
button.accessibilityIdentifier = "\(title)"
}

button.addTarget(self, action: action, for: .touchUpInside)
button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 10, bottom: 4, right: 10)
Expand Down
1 change: 1 addition & 0 deletions Sources/Mantis/RotationDial/RotationDialPlate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,6 @@ class RotationDialPlate: UIView {

func reset() {
transform = .identity
layer.sublayers?.forEach({ $0.removeFromSuperlayer() })
}
}

0 comments on commit f432e36

Please sign in to comment.