I'm using SnapKit for layout in my iOS project and in landscape mode i want to add some constraints at the bottom.
with the following code everything works good.
containerView.snp.updateConstraints { (update) in
update.left.equalToSuperview().offset(58)
update.top.equalToSuperview().offset(0)
if #available(iOS 11.0, *), UIDevice.isIphoneX {
let bottomPadding = self.viewController?.view.safeAreaInsets.bottom
update.bottom.equalToSuperview().offset(-bottomPadding!)
}
}
although i would like to make it more dynamic from a function something like this
func safeAreaEdge(_ view: UIView, _ edgePad: CGFloat) -> CGFloat {
if #available(iOS 11.0, *), UIDevice.isIphoneX {
let padding = view.safeAreaInsets.edgePad
return padding
} else {
return CGFloat(0.0)
}
}
So i can get the padding like this safeAreaEdge(view, bottom)
But i get an error
Value of type 'UIEdgeInsets' has no member 'edgePad'
Why I know that i have only those options top,bottom,right,left
from safeAreaInsets
But is there any efficient way to make it dynamic ?