Skip to content

Commit

Permalink
Fix Issue #628
Browse files Browse the repository at this point in the history
  • Loading branch information
scenee committed May 25, 2024
1 parent 0094797 commit 3221d0c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Sources/SurfaceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,30 @@ public class SurfaceView: UIView {
let leftConstraint = contentView.leftAnchor.constraint(equalTo: leftAnchor, constant: containerMargins.left + contentPadding.left)
let rightConstraint = rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: containerMargins.right + contentPadding.right)
let bottomConstraint = bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: containerMargins.bottom + contentPadding.bottom)
NSLayoutConstraint.activate([

var constraints = [
topConstraint,
leftConstraint,
rightConstraint,
bottomConstraint,
].map {
bottomConstraint
]

// Added this constraints for UICollectionView using UICollectionViewCompositionalLayout.
// It's seemingly obvious, but the UICollectionView doesn't work without setting it.
switch position {
case .top, .bottom:
constraints += [
heightAnchor.constraint(greaterThanOrEqualToConstant: 1.0)
]
case .left, .right:
constraints += [
widthAnchor.constraint(greaterThanOrEqualToConstant: 1.0)
]
}

NSLayoutConstraint.activate(
constraints
.map {
switch mode {
case .static:
$0.priority = .required
Expand Down

0 comments on commit 3221d0c

Please sign in to comment.