2020-04-14 07:07:37 +02:00
|
|
|
|
|
|
|
extension UIView {
|
|
|
|
|
2022-03-02 07:21:10 +01:00
|
|
|
convenience init(wrapping view: UIView, withInsets insets: UIEdgeInsets, shouldAdaptForIPad: Bool = false) {
|
2020-04-14 07:07:37 +02:00
|
|
|
self.init()
|
|
|
|
addSubview(view)
|
2022-03-02 07:21:10 +01:00
|
|
|
if UIDevice.current.isIPad && shouldAdaptForIPad {
|
|
|
|
view.set(.width, to: Values.iPadButtonWidth)
|
|
|
|
view.center(in: self)
|
|
|
|
} else {
|
|
|
|
view.pin(.leading, to: .leading, of: self, withInset: insets.left)
|
|
|
|
self.pin(.trailing, to: .trailing, of: view, withInset: insets.right)
|
|
|
|
}
|
2020-04-14 07:07:37 +02:00
|
|
|
view.pin(.top, to: .top, of: self, withInset: insets.top)
|
|
|
|
self.pin(.bottom, to: .bottom, of: view, withInset: insets.bottom)
|
|
|
|
}
|
|
|
|
}
|