mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
fix(ios): Shadow layer origin point update (#10376)
This commit is contained in:

committed by
GitHub

parent
39eed526c1
commit
f54ebbb2bf
@ -169,8 +169,9 @@ export class View extends ViewCommon implements ViewDefinition {
|
|||||||
CATransaction.setDisableActions(true);
|
CATransaction.setDisableActions(true);
|
||||||
|
|
||||||
if (nativeView.outerShadowContainerLayer) {
|
if (nativeView.outerShadowContainerLayer) {
|
||||||
|
const { x: originX, y: originY }: CGPoint = nativeView.outerShadowContainerLayer.anchorPoint;
|
||||||
nativeView.outerShadowContainerLayer.bounds = nativeView.bounds;
|
nativeView.outerShadowContainerLayer.bounds = nativeView.bounds;
|
||||||
nativeView.outerShadowContainerLayer.position = CGPointMake(frame.origin.x + frame.size.width / 2, frame.origin.y + frame.size.height / 2);
|
nativeView.outerShadowContainerLayer.position = CGPointMake(frame.origin.x + frame.size.width * originX, frame.origin.y + frame.size.height * originY);
|
||||||
}
|
}
|
||||||
|
|
||||||
CATransaction.setDisableActions(false);
|
CATransaction.setDisableActions(false);
|
||||||
@ -450,11 +451,27 @@ export class View extends ViewCommon implements ViewDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public updateOriginPoint(originX: number, originY: number) {
|
public updateOriginPoint(originX: number, originY: number) {
|
||||||
|
const nativeView: NativeScriptUIView = <NativeScriptUIView>this.nativeViewProtected;
|
||||||
const newPoint = CGPointMake(originX, originY);
|
const newPoint = CGPointMake(originX, originY);
|
||||||
this.nativeViewProtected.layer.anchorPoint = newPoint;
|
|
||||||
|
// Disable CALayer animatable property changes
|
||||||
|
CATransaction.setDisableActions(true);
|
||||||
|
|
||||||
|
nativeView.layer.anchorPoint = newPoint;
|
||||||
if (this._cachedFrame) {
|
if (this._cachedFrame) {
|
||||||
this._setNativeViewFrame(this.nativeViewProtected, this._cachedFrame);
|
this._setNativeViewFrame(nativeView, this._cachedFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure new origin also applies to outer shadow layers
|
||||||
|
if (nativeView.outerShadowContainerLayer) {
|
||||||
|
// This is the new frame after view origin point update
|
||||||
|
const frame = nativeView.frame;
|
||||||
|
|
||||||
|
nativeView.outerShadowContainerLayer.anchorPoint = newPoint;
|
||||||
|
nativeView.outerShadowContainerLayer.position = CGPointMake(frame.origin.x + frame.size.width * originX, frame.origin.y + frame.size.height * originY);
|
||||||
|
}
|
||||||
|
|
||||||
|
CATransaction.setDisableActions(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// By default we update the view's presentation layer when setting backgroundColor and opacity properties.
|
// By default we update the view's presentation layer when setting backgroundColor and opacity properties.
|
||||||
|
@ -1125,9 +1125,12 @@ function drawBoxShadow(view: View): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since shadow layer is added to view layer's superlayer, we have to be more specific about shadow layer position
|
|
||||||
outerShadowContainerLayer.bounds = bounds;
|
outerShadowContainerLayer.bounds = bounds;
|
||||||
outerShadowContainerLayer.position = CGPointMake(viewFrame.origin.x + viewFrame.size.width / 2, viewFrame.origin.y + viewFrame.size.height / 2);
|
outerShadowContainerLayer.anchorPoint = layer.anchorPoint;
|
||||||
|
|
||||||
|
// Since shadow uses superlayer's coordinate system, we have to be more specific about shadow layer position
|
||||||
|
const { x: originX, y: originY }: CGPoint = outerShadowContainerLayer.anchorPoint;
|
||||||
|
outerShadowContainerLayer.position = CGPointMake(viewFrame.origin.x + viewFrame.size.width * originX, viewFrame.origin.y + viewFrame.size.height * originY);
|
||||||
|
|
||||||
// Inherit view visibility values
|
// Inherit view visibility values
|
||||||
outerShadowContainerLayer.opacity = layer.opacity;
|
outerShadowContainerLayer.opacity = layer.opacity;
|
||||||
|
Reference in New Issue
Block a user