Files
Folo/apps/mobile/native/ios/ImageViewer_swift/UIView_Extensions.swift
T
Innei 6e6b7e3936 feat(ios): Use the native image preview component (#3017)
* init

* done

* feat(mobile): integrate Galeria component for image preview and carousel

Signed-off-by: Innei <tukon479@gmail.com>

* revert

Signed-off-by: Innei <tukon479@gmail.com>

* chore: auto-fix linting and formatting issues

---------

Signed-off-by: Innei <tukon479@gmail.com>
2025-03-10 22:41:20 +08:00

21 lines
942 B
Swift

import UIKit
extension UIView {
func bindFrameToSuperview(top:CGFloat = 0, leading: CGFloat = 0, trailing:CGFloat = 0, bottom:CGFloat = 0) {
guard let superview = self.superview else { return }
self.translatesAutoresizingMaskIntoConstraints = false
self.topAnchor.constraint(equalTo: superview.topAnchor, constant: top).isActive = true
self.leadingAnchor.constraint(equalTo: superview.leadingAnchor, constant: leading).isActive = true
superview.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: trailing).isActive = true
superview.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: bottom).isActive = true
}
func bindFrameToSuperview(margin:CGFloat) {
bindFrameToSuperview(top: margin, leading: margin, trailing: margin, bottom: margin)
}
func frameRelativeToWindow() -> CGRect {
return convert(bounds, to: nil)
}
}