File tree Expand file tree Collapse file tree 3 files changed +22
-22
lines changed
Example/PinLayoutSample/UI/Examples/IntroObjectiveC Expand file tree Collapse file tree 3 files changed +22
-22
lines changed Original file line number Diff line number Diff line change @@ -72,26 +72,26 @@ - (void) layoutSubviews {
7272// [[[[segmented.pinObjc rightOf:logo aligned:VerticalAlignTop] rightWithInsets:safeArea] marginHorizontal:margin] layout];
7373// [[[[[[textLabel.pinObjc belowOf:segmented aligned:HorizontalAlignLeft] widthOf:segmented] pinEdges] marginTop:margin] sizeToFit:FitWidth] layout];
7474// [[[[[separatorView.pinObjc belowOfViews:@[logo, textLabel] aligned:HorizontalAlignLeft] rightTo:segmented.edge.right] height:1] marginTop:margin] layout];
75- [ logo.pinObjc
75+ logo.pinObjc
7676 .topInsets (safeArea)
7777 .leftInsets (safeArea)
7878 .width (100 ).aspectRatio ()
79- .margin (margin) layout ] ;
80- [ segmented.pinObjc
79+ .margin (margin). layout () ;
80+ segmented.pinObjc
8181 .rightOfAligned (logo, VerticalAlignTop)
8282 .rightInsets (safeArea)
83- .marginHorizontal (margin) layout ] ;
84- [ textLabel.pinObjc
83+ .marginHorizontal (margin). layout () ;
84+ textLabel.pinObjc
8585 .belowOfAligned (segmented, HorizontalAlignLeft)
8686 .widthOf (segmented)
8787 .pinEdges ()
8888 .marginTop (margin)
89- .sizeToFitType (FitWidth) layout ] ;
90- [ separatorView.pinObjc
89+ .sizeToFitType (FitWidth). layout () ;
90+ separatorView.pinObjc
9191 .belowOfViewsAligned (@[logo, textLabel], HorizontalAlignLeft)
9292 .rightToEdge (segmented.edge .right )
9393 .height (1 )
94- .marginTop (margin) layout ] ;
94+ .marginTop (margin). layout () ;
9595}
9696
9797- (void ) setLayoutGuidesTop : (CGFloat)top {
Original file line number Diff line number Diff line change @@ -33,15 +33,7 @@ import AppKit
3333 #if os(iOS) || os(tvOS)
3434 var safeArea : PEdgeInsets { get }
3535 #endif
36-
37- /**
38- With the Objective-C interface, you must call the \"layout\" method to ensure the view is layouted correctly.
39- Ex:
40- [[[textLabel.pin_objc top] left] layout];"
41- [[[textLabel.pin_objc top] left] layout];"
42- */
43- func layout( )
44-
36+
4537 typealias POVoid = ( ) -> PinLayoutObjC ?
4638 typealias POValue = ( _ value: CGFloat ) -> PinLayoutObjC ?
4739 typealias POEdgeInsets = ( _ insets: PEdgeInsets ) -> PinLayoutObjC ?
@@ -56,6 +48,13 @@ import AppKit
5648 typealias POWrapTypeInsets = ( _ type: WrapType , _ insets: PEdgeInsets ) -> PinLayoutObjC ?
5749 typealias POFitType = ( _ type: Fit ) -> PinLayoutObjC ?
5850
51+ /**
52+ With the Objective-C interface, you must call the \"layout\" method to ensure the view is layouted correctly.
53+ Ex:
54+ textLabel.pinObjc.top().left().layout()
55+ */
56+ var layout : POVoid { get }
57+
5958 var top : POVoid { get }
6059 var topValue : POValue { get }
6160 var topPercent : POValue { get }
Original file line number Diff line number Diff line change @@ -70,11 +70,12 @@ import AppKit
7070 }
7171 }
7272
73- func layout( ) {
74- // With objective-c PinLayoutObjCImpl instance are sometimes deallocated only after the context has been quit. For this reason
75- // developpers must call the layout: method implicetely.
76- impl? . layout ( )
77- impl = nil
73+ var layout : POVoid {
74+ return { [ weak self] in
75+ _ = self ? . impl? . layout ( )
76+ self ? . impl = nil
77+ return self
78+ }
7879 }
7980
8081 var top : POVoid {
You can’t perform that action at this time.
0 commit comments