@@ -594,43 +594,26 @@ class PinLayoutImpl: PinLayout {
594594 //
595595 @discardableResult
596596 func size( _ size: CGSize ) -> PinLayout {
597- if isSizeNotSet ( { return " size(CGSize(width: \( size. width) , height: \( size. height) )) " } ) {
598- width ( size. width)
599- height ( size. height)
600- }
601- return self
597+ return setSize ( size, { return " size(CGSize(width: \( size. width) , height: \( size. height) )) " } )
602598 }
603599
604600 @discardableResult
605601 func size( _ sideLength: CGFloat ) -> PinLayout {
606- if isSizeNotSet ( { return " size(sideLength: \( sideLength) ) " } ) {
607- width ( sideLength)
608- height ( sideLength)
609- }
610- return self
602+ return setSize ( CGSize ( width: sideLength, height: sideLength) , { return " size(sideLength: \( sideLength) ) " } )
611603 }
612604
613605 @discardableResult
614606 func size( _ percent: Percent ) -> PinLayout {
615607 func context( ) -> String { return " size( \( percent) ) " }
616- if isSizeNotSet ( context) {
617- guard let layoutSuperview = layoutSuperview ( context) else { return self }
618- setWidth ( percent. of ( layoutSuperview. frame. width) , context)
619- setHeight ( percent. of ( layoutSuperview. frame. height) , context)
620- }
621- return self
608+ guard let layoutSuperview = layoutSuperview ( context) else { return self }
609+ let size = CGSize ( width: percent. of ( layoutSuperview. frame. width) , height: percent. of ( layoutSuperview. frame. height) )
610+ return setSize ( size, context)
622611 }
623612
624613 @discardableResult
625614 func size( of view: UIView ) -> PinLayout {
626615 func context( ) -> String { return " size(of \( view) ) " }
627- let viewSize = view. frame. size
628-
629- if isSizeNotSet ( context) {
630- setWidth ( viewSize. width, context)
631- setHeight ( viewSize. height, context)
632- }
633- return self
616+ return setSize ( view. frame. size, context)
634617 }
635618
636619 @discardableResult
@@ -867,7 +850,7 @@ extension PinLayoutImpl {
867850
868851 if let _left = _left, let _right = _right {
869852 warnConflict ( context, [ " left " : _left, " right " : _right] )
870- } else if let width = width {
853+ } else if let width = width, width != value {
871854 warnPropertyAlreadySet ( " width " , propertyValue: width, context)
872855 } else {
873856 width = value
@@ -883,27 +866,18 @@ extension PinLayoutImpl {
883866
884867 if let _top = _top, let _bottom = _bottom {
885868 warnConflict ( context, [ " top " : _top, " bottom " : _bottom] )
886- } else if let height = height {
869+ } else if let height = height, height != value {
887870 warnPropertyAlreadySet ( " height " , propertyValue: height, context)
888871 } else {
889872 height = value
890873 }
891874 return self
892875 }
893876
894- fileprivate func isSizeNotSet( _ context: Context ) -> Bool {
895- if let _top = _top, let _bottom = _bottom {
896- warnConflict ( context, [ " top " : _top, " bottom " : _bottom] )
897- return false
898- } else if let height = height {
899- warnConflict ( context, [ " height " : height] )
900- return false
901- } else if let width = width {
902- warnConflict ( context, [ " width " : width] )
903- return false
904- } else {
905- return true
906- }
877+ fileprivate func setSize( _ size: CGSize , _ context: Context ) -> PinLayout {
878+ setWidth ( size. width, { return " \( context ( ) ) 's width " } )
879+ setHeight ( size. height, { return " \( context ( ) ) 's height " } )
880+ return self
907881 }
908882
909883 fileprivate func computeCoordinates( _ point: CGPoint , _ layoutSuperview: UIView , _ referenceView: UIView , _ referenceSuperview: UIView ) -> CGPoint {
0 commit comments