From e47880829a8b15d18af2ae9178d04eec556f0976 Mon Sep 17 00:00:00 2001 From: Asif Habib Date: Sat, 29 Aug 2020 01:04:21 +0500 Subject: [PATCH] Added the function which will prevent some views to expand or shrink. --- SteviaPod/Classes/Stevia+Constraints.swift | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/SteviaPod/Classes/Stevia+Constraints.swift b/SteviaPod/Classes/Stevia+Constraints.swift index e4d7b1e..15b27f9 100644 --- a/SteviaPod/Classes/Stevia+Constraints.swift +++ b/SteviaPod/Classes/Stevia+Constraints.swift @@ -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