@@ -31,34 +31,26 @@ public class AnimatedImageViewWrapper : PlatformView {
31
31
ctx. setShouldAntialias ( shouldAntialias)
32
32
}
33
33
34
+ #if os(macOS)
35
+ public override func layout( ) {
36
+ super. layout ( )
37
+ wrapped. frame = self . bounds
38
+ }
39
+ #else
40
+ public override func layoutSubviews( ) {
41
+ super. layoutSubviews ( )
42
+ wrapped. frame = self . bounds
43
+ }
44
+ #endif
45
+
34
46
public override init ( frame frameRect: CGRect ) {
35
47
super. init ( frame: frameRect)
36
48
addSubview ( wrapped)
37
- wrapped. bindFrameToSuperviewBounds ( )
38
49
}
39
50
40
51
public required init ? ( coder: NSCoder ) {
41
52
super. init ( coder: coder)
42
53
addSubview ( wrapped)
43
- wrapped. bindFrameToSuperviewBounds ( )
44
- }
45
- }
46
-
47
- extension PlatformView {
48
- /// Adds constraints to this `UIView` instances `superview` object to make sure this always has the same size as the superview.
49
- /// Please note that this has no effect if its `superview` is `nil` – add this `UIView` instance as a subview before calling this.
50
- func bindFrameToSuperviewBounds( ) {
51
- guard let superview = self . superview else {
52
- print ( " Error! `superview` was nil – call `addSubview(view: UIView)` before calling `bindFrameToSuperviewBounds()` to fix this. " )
53
- return
54
- }
55
-
56
- self . translatesAutoresizingMaskIntoConstraints = false
57
- self . topAnchor. constraint ( equalTo: superview. topAnchor, constant: 0 ) . isActive = true
58
- self . bottomAnchor. constraint ( equalTo: superview. bottomAnchor, constant: 0 ) . isActive = true
59
- self . leadingAnchor. constraint ( equalTo: superview. leadingAnchor, constant: 0 ) . isActive = true
60
- self . trailingAnchor. constraint ( equalTo: superview. trailingAnchor, constant: 0 ) . isActive = true
61
-
62
54
}
63
55
}
64
56
0 commit comments