@@ -725,20 +725,15 @@ 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
- // 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 ) ;
728
+ const layerBounds = layer . bounds ;
734
729
735
730
layer . borderColor = null ;
736
731
layer . borderWidth = 0 ;
737
732
layer . cornerRadius = 0 ;
738
733
739
- const cappedOuterRadii = calculateNonUniformBorderCappedRadii ( drawingBounds , background ) ;
734
+ const cappedOuterRadii = calculateNonUniformBorderCappedRadii ( layerBounds , background ) ;
740
735
if ( nativeView . maskType === iosViewUtils . LayerMask . BORDER && layer . mask instanceof CAShapeLayer ) {
741
- layer . mask . path = generateNonUniformBorderOuterClipPath ( drawingBounds , cappedOuterRadii ) ;
736
+ layer . mask . path = generateNonUniformBorderOuterClipPath ( layerBounds , cappedOuterRadii ) ;
742
737
}
743
738
744
739
if ( background . hasBorderWidth ( ) ) {
@@ -750,15 +745,21 @@ function drawNonUniformBorders(nativeView: NativeScriptUIView, background: Backg
750
745
}
751
746
752
747
if ( background . hasUniformBorderColor ( ) ) {
748
+ // Use anti-aliasing or borders will draw incorrectly at times
749
+ nativeView . borderLayer . shouldRasterize = true ;
750
+ nativeView . borderLayer . rasterizationScale = Screen . mainScreen . scale ;
753
751
nativeView . borderLayer . fillColor = background . borderTopColor ?. ios ?. CGColor || UIColor . blackColor . CGColor ;
754
- nativeView . borderLayer . path = generateNonUniformBorderInnerClipPath ( drawingBounds , background , cappedOuterRadii ) ;
752
+ nativeView . borderLayer . path = generateNonUniformBorderInnerClipPath ( layerBounds , background , cappedOuterRadii ) ;
755
753
} else {
756
754
// Non-uniform borders need more layers in order to display multiple colors at the same time
757
755
let borderTopLayer , borderRightLayer , borderBottomLayer , borderLeftLayer ;
758
756
759
757
if ( ! nativeView . hasNonUniformBorderColor ) {
760
758
const maskLayer = CAShapeLayer . new ( ) ;
761
759
maskLayer . fillRule = kCAFillRuleEvenOdd ;
760
+ // Use anti-aliasing or borders will draw incorrectly at times
761
+ maskLayer . shouldRasterize = true ;
762
+ maskLayer . rasterizationScale = Screen . mainScreen . scale ;
762
763
nativeView . borderLayer . mask = maskLayer ;
763
764
764
765
borderTopLayer = CAShapeLayer . new ( ) ;
@@ -779,7 +780,7 @@ function drawNonUniformBorders(nativeView: NativeScriptUIView, background: Backg
779
780
borderLeftLayer = nativeView . borderLayer . sublayers [ 3 ] ;
780
781
}
781
782
782
- const paths = generateNonUniformMultiColorBorderPaths ( drawingBounds , background ) ;
783
+ const paths = generateNonUniformMultiColorBorderPaths ( layerBounds , background ) ;
783
784
784
785
borderTopLayer . fillColor = background . borderTopColor ?. ios ?. CGColor || UIColor . blackColor . CGColor ;
785
786
borderTopLayer . path = paths [ 0 ] ;
@@ -792,7 +793,7 @@ function drawNonUniformBorders(nativeView: NativeScriptUIView, background: Backg
792
793
793
794
// Clip inner area to create borders
794
795
if ( nativeView . borderLayer . mask instanceof CAShapeLayer ) {
795
- nativeView . borderLayer . mask . path = generateNonUniformBorderInnerClipPath ( drawingBounds , background , cappedOuterRadii ) ;
796
+ nativeView . borderLayer . mask . path = generateNonUniformBorderInnerClipPath ( layerBounds , background , cappedOuterRadii ) ;
796
797
}
797
798
}
798
799
}
0 commit comments