Skip to content

Commit

Permalink
Added the function which will prevent some views to expand or shrink.
Browse files Browse the repository at this point in the history
  • Loading branch information
asifhabib committed Aug 28, 2020
1 parent 19b6d7f commit e478808
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions SteviaPod/Classes/Stevia+Constraints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,37 @@ public extension UIView {
return self
}

/// It will increase the Compressiong Resistance Priority on the horizontal axis.
func doNotCompressHorizontal(){
doNotCompress(for: .horizontal)
}

/// It will increase the Compressiong Resistance Priority on the vertical axis.
func doNotCompressVertical(){
doNotCompress(for: .vertical)
}

/// It will increase the Content Hugging Priority on the horizontal axis.
func doNotExpandHorizontal(){
doNotExpand(for: .horizontal)
}

/// It will increase the Content Hugging Priority on the vertical axis.
func doNotExpandVertical(){
doNotExpand(for: .horizontal)
}

/// /// It will increase the Compressiong Resistance Priority on axis.
/// - Parameter axis: axis on which Compressiong Resistance Priority will be increased. Possible value could be .horizontal and .horizontal
func doNotCompress(for axis: NSLayoutConstraint.Axis) {
setContentCompressionResistancePriority(.required, for: axis)
}

/// It will increase the Content Hugging Priority priority on axis.
/// - Parameter axis: axis on which Content Hugging Priority will be increased. Possible value could be .horizontal and .horizontal
func doNotExpand(for axis: NSLayoutConstraint.Axis) {
setContentHuggingPriority(.required, for: axis)
}

}
#endif

0 comments on commit e478808

Please sign in to comment.