@@ -725,15 +725,20 @@ function calculateNonUniformBorderCappedRadii(bounds: CGRect, background: Backgr
725
725
726
726
function drawNonUniformBorders ( nativeView : NativeScriptUIView , background : BackgroundDefinition ) : void {
727
727
const layer : CALayer = nativeView . layer ;
728
- const layerBounds = layer . bounds ;
728
+ // There are some cases like drawing when Core Animation API has trouble with fractional coordinates,
729
+ // so get the difference between the fractional and integral origin points and use it as offset
730
+ const { x : frameX , y : frameY } = layer . frame . origin ;
731
+ const offsetX = Math . round ( frameX ) - frameX ;
732
+ const offsetY = Math . round ( frameY ) - frameY ;
733
+ const drawingBounds = CGRectOffset ( layer . bounds , offsetX , offsetY ) ;
729
734
730
735
layer . borderColor = null ;
731
736
layer . borderWidth = 0 ;
732
737
layer . cornerRadius = 0 ;
733
738
734
- const cappedOuterRadii = calculateNonUniformBorderCappedRadii ( layerBounds , background ) ;
739
+ const cappedOuterRadii = calculateNonUniformBorderCappedRadii ( drawingBounds , background ) ;
735
740
if ( nativeView . maskType === iosViewUtils . LayerMask . BORDER && layer . mask instanceof CAShapeLayer ) {
736
- layer . mask . path = generateNonUniformBorderOuterClipPath ( layerBounds , cappedOuterRadii ) ;
741
+ layer . mask . path = generateNonUniformBorderOuterClipPath ( drawingBounds , cappedOuterRadii ) ;
737
742
}
738
743
739
744
if ( background . hasBorderWidth ( ) ) {
@@ -746,7 +751,7 @@ function drawNonUniformBorders(nativeView: NativeScriptUIView, background: Backg
746
751
747
752
if ( background . hasUniformBorderColor ( ) ) {
748
753
nativeView . borderLayer . fillColor = background . borderTopColor ?. ios ?. CGColor || UIColor . blackColor . CGColor ;
749
- nativeView . borderLayer . path = generateNonUniformBorderInnerClipPath ( layerBounds , background , cappedOuterRadii ) ;
754
+ nativeView . borderLayer . path = generateNonUniformBorderInnerClipPath ( drawingBounds , background , cappedOuterRadii ) ;
750
755
} else {
751
756
// Non-uniform borders need more layers in order to display multiple colors at the same time
752
757
let borderTopLayer , borderRightLayer , borderBottomLayer , borderLeftLayer ;
@@ -774,7 +779,7 @@ function drawNonUniformBorders(nativeView: NativeScriptUIView, background: Backg
774
779
borderLeftLayer = nativeView . borderLayer . sublayers [ 3 ] ;
775
780
}
776
781
777
- const paths = generateNonUniformMultiColorBorderPaths ( layerBounds , background ) ;
782
+ const paths = generateNonUniformMultiColorBorderPaths ( drawingBounds , background ) ;
778
783
779
784
borderTopLayer . fillColor = background . borderTopColor ?. ios ?. CGColor || UIColor . blackColor . CGColor ;
780
785
borderTopLayer . path = paths [ 0 ] ;
@@ -787,7 +792,7 @@ function drawNonUniformBorders(nativeView: NativeScriptUIView, background: Backg
787
792
788
793
// Clip inner area to create borders
789
794
if ( nativeView . borderLayer . mask instanceof CAShapeLayer ) {
790
- nativeView . borderLayer . mask . path = generateNonUniformBorderInnerClipPath ( layerBounds , background , cappedOuterRadii ) ;
795
+ nativeView . borderLayer . mask . path = generateNonUniformBorderInnerClipPath ( drawingBounds , background , cappedOuterRadii ) ;
791
796
}
792
797
}
793
798
}
0 commit comments