Skip to content

Commit 120230c

Browse files
author
Hristo Hristov
authored
ios cornder radius is rendered as circle now (NativeScript#3915)
* ios cornder radius is rendered as circle now * fix failing test
1 parent e802206 commit 120230c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tests/app/ui/view/view-tests-common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ export function testBorderWidth() {
818818
export function testCornerRadius() {
819819
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<View>) {
820820
const lbl = views[0];
821+
TKUnit.waitUntilReady(() => lbl.isLayoutValid);
821822
const expectedValue = <number>lbl.borderRadius * utils.layout.getDisplayDensity();
822823
const actualValue = definition.getUniformNativeCornerRadius(lbl);
823824
TKUnit.assertAreClose(actualValue, expectedValue, 0.01, "borderRadius");

tns-core-modules/ui/styling/background.ios.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export module ios {
3737
const borderColor = background.getUniformBorderColor();
3838
layer.borderColor = !borderColor ? undefined : borderColor.ios.CGColor;
3939
layer.borderWidth = layout.toDeviceIndependentPixels(background.getUniformBorderWidth());
40-
layer.cornerRadius = layout.toDeviceIndependentPixels(background.getUniformBorderRadius());
40+
const renderSize = view.getActualSize() || { width: 0, height: 0 };
41+
const cornerRadius = layout.toDeviceIndependentPixels(background.getUniformBorderRadius());
42+
layer.cornerRadius = Math.min(Math.min(renderSize.width / 2, renderSize.height / 2), cornerRadius);
4143
}
4244
else {
4345
drawNonUniformBorders(nativeView, background);

0 commit comments

Comments
 (0)