Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): restored borderRadius setter #11951

Merged
merged 3 commits into from Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiUIView.m
Expand Up @@ -674,9 +674,11 @@ - (void)addCornerRadius:(NSArray *)radiusArray toLayer:(CALayer *)viewLayer
bottomLeftRadius = radius;
topRightRadius = radius;
} else if (radiusArray.count == 1) {
// For same corner radius, no need to create bezier path. Use CALayer's cornerRadius.
viewLayer.cornerRadius = [self radiusFromObject:radiusArray[0]];
return;
CGFloat radius = [self radiusFromObject:radiusArray[0]];
topLeftRadius = radius;
topRightRadius = radius;
bottomRightRadius = radius;
bottomLeftRadius = radius;
}

CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] initWithLayer:viewLayer];
Expand Down Expand Up @@ -727,6 +729,11 @@ - (void)updateBorderRadius:(id)radius
[self updateClipping];
}

- (void)setBorderRadius_:(id)radius
{
[self updateBorderRadius:radius];
}

- (void)setAnchorPoint_:(id)point
{
self.layer.anchorPoint = [TiUtils pointValue:point];
Expand Down
33 changes: 33 additions & 0 deletions tests/Resources/ti.ui.view.test.js
Expand Up @@ -1092,6 +1092,39 @@ describe('Titanium.UI.View', function () {
win.add(outerView);
win.open();
});

it.ios('set property post layout', finish => {
win = Ti.UI.createWindow({ backgroundColor: 'blue' });
const outerView = Ti.UI.createView({
width: '90px',
height: '90px',
backgroundColor: 'green'
});
const view = Ti.UI.createView({
width: '60px',
height: '60px',
backgroundColor: 'yellow'
});

win.addEventListener('postlayout', function postlayout() {
win.removeEventListener('postlayout', postlayout); // only run once
try {
view.borderRadius = [ '12px', 12 ];
should(view.borderRadius).be.an.Array();
should(view.borderRadius.length).eql(2);
should(view.borderRadius).eql([ '12px', 12 ]);
// should be the exact same as above
should(outerView).matchImage(`snapshots/borderRadius12px_12_${density}x.png`);
} catch (err) {
return finish(err);
}
finish();
});

outerView.add(view);
win.add(outerView);
win.open();
});
});

it.android('touchFeedback', finish => {
Expand Down