MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / _setShadow

Method _setShadow

packages/core/ui/text-base/index.ios.ts:453–483  ·  view source on GitHub ↗
(value: ShadowCSSValues)

Source from the content-addressed store, hash-verified

451 }
452
453 _setShadow(value: ShadowCSSValues): void {
454 const layer: CALayer = this.nativeTextViewProtected.layer;
455
456 if (isNullOrUndefined(value)) {
457 // clear the text shadow
458 layer.shadowOpacity = 0;
459 layer.shadowRadius = 0;
460 layer.shadowColor = UIColor.clearColor;
461 layer.shadowOffset = CGSizeMake(0, 0);
462 return;
463 }
464
465 // shadow opacity is handled on the shadow's color instance
466 layer.shadowOpacity = value.color?.a ? value.color.a / 255 : 1;
467 layer.shadowColor = value.color.ios.CGColor;
468 layer.shadowRadius = layout.toDeviceIndependentPixels(Length.toDevicePixels(value.blurRadius, 0));
469
470 // prettier-ignore
471 layer.shadowOffset = CGSizeMake(
472 layout.toDeviceIndependentPixels(Length.toDevicePixels(value.offsetX, 0)),
473 layout.toDeviceIndependentPixels(Length.toDevicePixels(value.offsetY, 0))
474 );
475
476 layer.masksToBounds = false;
477
478 // NOTE: generally should not need shouldRasterize
479 // however for various detailed animation work which involves text-shadow applicable layers, we may want to give users the control of enabling this with text-shadow
480 // if (!(this.nativeTextViewProtected instanceof UITextView)) {
481 // layer.shouldRasterize = true;
482 // }
483 }
484}
485
486export function getTransformedText(text: string, textTransform: CoreTypes.TextTransformType): string {

Callers 1

Calls 1

isNullOrUndefinedFunction · 0.90

Tested by

no test coverage detected