@@ -877,47 +877,133 @@ class PinLayoutImpl: PinLayout {
877877 return self
878878 }
879879
880+ @discardableResult
881+ func marginTop( _ percent: Percent ) -> PinLayout {
882+ func context( ) -> String { return " marginTop( \( percent. description) ) " }
883+ return marginTop ( percent, context)
884+ }
885+
886+ @discardableResult
887+ private func marginTop( _ percent: Percent , _ context: Context ) -> Self {
888+ guard let layoutSuperviewRect = layoutSuperviewRect ( context) else { return self }
889+ marginTop = percent. of ( layoutSuperviewRect. height)
890+ return self
891+ }
892+
880893 @discardableResult
881894 func marginLeft( _ value: CGFloat ) -> PinLayout {
882895 marginLeft = value
883896 return self
884897 }
885898
899+ @discardableResult
900+ func marginLeft( _ percent: Percent ) -> PinLayout {
901+ func context( ) -> String { return " marginLeft( \( percent. description) ) " }
902+ return marginLeft ( percent, context)
903+ }
904+
905+ @discardableResult
906+ private func marginLeft( _ percent: Percent , _ context: Context ) -> Self {
907+ guard let layoutSuperviewRect = layoutSuperviewRect ( context) else { return self }
908+ marginLeft = percent. of ( layoutSuperviewRect. width)
909+ return self
910+ }
911+
886912 @discardableResult
887913 func marginBottom( _ value: CGFloat ) -> PinLayout {
888914 marginBottom = value
889915 return self
890916 }
891917
918+ @discardableResult
919+ func marginBottom( _ percent: Percent ) -> PinLayout {
920+ func context( ) -> String { return " marginBottom( \( percent. description) ) " }
921+ return marginBottom ( percent, context)
922+ }
923+
924+ @discardableResult
925+ private func marginBottom( _ percent: Percent , _ context: Context ) -> Self {
926+ guard let layoutSuperviewRect = layoutSuperviewRect ( context) else { return self }
927+ marginBottom = percent. of ( layoutSuperviewRect. height)
928+ return self
929+ }
930+
892931 @discardableResult
893932 func marginRight( _ value: CGFloat ) -> PinLayout {
894933 marginRight = value
895934 return self
896935 }
936+
937+ @discardableResult
938+ func marginRight( _ percent: Percent ) -> PinLayout {
939+ func context( ) -> String { return " marginRight( \( percent. description) ) " }
940+ return marginRight ( percent, context)
941+ }
942+
943+ @discardableResult
944+ private func marginRight( _ percent: Percent , _ context: Context ) -> Self {
945+ guard let layoutSuperviewRect = layoutSuperviewRect ( context) else { return self }
946+ marginRight = percent. of ( layoutSuperviewRect. width)
947+ return self
948+ }
897949
898950 @discardableResult
899951 func marginStart( _ value: CGFloat ) -> PinLayout {
900952 return isLTR ( ) ? marginLeft ( value) : marginRight ( value)
901953 }
954+
955+ @discardableResult
956+ func marginStart( _ percent: Percent ) -> PinLayout {
957+ func context( ) -> String { return " marginStart( \( percent. description) ) " }
958+ return isLTR ( ) ? marginLeft ( percent, context) : marginRight ( percent, context)
959+ }
902960
903961 @discardableResult
904962 func marginEnd( _ value: CGFloat ) -> PinLayout {
905963 return isLTR ( ) ? marginRight ( value) : marginLeft ( value)
906964 }
907965
966+ @discardableResult
967+ func marginEnd( _ percent: Percent ) -> PinLayout {
968+ func context( ) -> String { return " marginEnd( \( percent. description) ) " }
969+ return isLTR ( ) ? marginRight ( percent, context) : marginLeft ( percent, context)
970+ }
971+
908972 @discardableResult
909973 func marginHorizontal( _ value: CGFloat ) -> PinLayout {
910974 marginLeft = value
911975 marginRight = value
912976 return self
913977 }
914978
979+ @discardableResult
980+ func marginHorizontal( _ percent: Percent ) -> PinLayout {
981+ func context( ) -> String { return " marginHorizontal( \( percent. description) ) " }
982+ return marginHorizontal ( percent, context)
983+ }
984+
985+ @discardableResult
986+ private func marginHorizontal( _ percent: Percent , _ context: Context ) -> Self {
987+ return marginLeft ( percent, context) . marginRight ( percent, context)
988+ }
989+
915990 @discardableResult
916991 func marginVertical( _ value: CGFloat ) -> PinLayout {
917992 marginTop = value
918993 marginBottom = value
919994 return self
920995 }
996+
997+ @discardableResult
998+ func marginVertical( _ percent: Percent ) -> PinLayout {
999+ func context( ) -> String { return " marginVertical( \( percent. description) ) " }
1000+ return marginVertical ( percent, context)
1001+ }
1002+
1003+ @discardableResult
1004+ private func marginVertical( _ percent: Percent , _ context: Context ) -> Self {
1005+ return marginTop ( percent, context) . marginBottom ( percent, context)
1006+ }
9211007
9221008 @discardableResult
9231009 func margin( _ insets: UIEdgeInsets ) -> PinLayout {
@@ -947,6 +1033,15 @@ class PinLayoutImpl: PinLayout {
9471033 return self
9481034 }
9491035
1036+ @discardableResult
1037+ func margin( _ percent: Percent ) -> PinLayout {
1038+ func context( ) -> String { return " margin( \( percent. description) ) " }
1039+ return marginTop ( percent, context)
1040+ . marginLeft ( percent, context)
1041+ . marginBottom ( percent, context)
1042+ . marginRight ( percent, context)
1043+ }
1044+
9501045 @discardableResult
9511046 func margin( _ top: CGFloat , _ left: CGFloat , _ bottom: CGFloat , _ right: CGFloat ) -> PinLayout {
9521047 marginTop = top
@@ -956,6 +1051,17 @@ class PinLayoutImpl: PinLayout {
9561051 return self
9571052 }
9581053
1054+ @discardableResult
1055+ func margin( _ top: Percent , _ left: Percent , _ bottom: Percent , _ right: Percent ) -> PinLayout {
1056+ func context( ) -> String {
1057+ return " margin(top: \( top. description) , left: \( left. description) , bottom: \( bottom. description) , right: \( right. description) "
1058+ }
1059+ return marginTop ( top, context)
1060+ . marginLeft ( left, context)
1061+ . marginBottom ( bottom, context)
1062+ . marginRight ( right, context)
1063+ }
1064+
9591065 @discardableResult func margin( _ vertical: CGFloat , _ horizontal: CGFloat ) -> PinLayout {
9601066 marginTop = vertical
9611067 marginLeft = horizontal
@@ -964,6 +1070,12 @@ class PinLayoutImpl: PinLayout {
9641070 return self
9651071 }
9661072
1073+ @discardableResult
1074+ func margin( _ vertical: Percent , _ horizontal: Percent ) -> PinLayout {
1075+ func context( ) -> String { return " margin(vertical: \( vertical. description) , horizontal: \( horizontal. description) " }
1076+ return marginVertical ( vertical, context) . marginHorizontal ( horizontal, context)
1077+ }
1078+
9671079 @discardableResult func margin( _ top: CGFloat , _ horizontal: CGFloat , _ bottom: CGFloat ) -> PinLayout {
9681080 marginTop = top
9691081 marginLeft = horizontal
@@ -972,6 +1084,12 @@ class PinLayoutImpl: PinLayout {
9721084 return self
9731085 }
9741086
1087+ @discardableResult
1088+ func margin( _ top: Percent , _ horizontal: Percent , _ bottom: Percent ) -> PinLayout {
1089+ func context( ) -> String { return " margin(top: \( top. description) , horizontal: \( horizontal. description) , bottom: \( bottom. description) " }
1090+ return marginTop ( top, context) . marginHorizontal ( horizontal, context) . marginBottom ( bottom, context)
1091+ }
1092+
9751093 @discardableResult
9761094 func pinEdges( ) -> PinLayout {
9771095 shouldPinEdges = true
0 commit comments