Clipping is required for iOS even with uniform borders, as long as the radius is > 0

This commit is contained in:
Panayot Cankov
2017-02-24 17:41:20 +02:00
parent 9113fa9ed8
commit 3066dbd072
4 changed files with 27 additions and 4 deletions

View File

@@ -914,6 +914,10 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
this.effectiveMarginTop = PercentLength.toDevicePixels(style.marginTop, 0, parentAvailableHeight);
this.effectiveMarginBottom = PercentLength.toDevicePixels(style.marginBottom, 0, parentAvailableHeight);
}
public _setNativeClipToBounds() {
//
}
}
ViewCommon.prototype._oldLeft = 0;

View File

@@ -13,6 +13,12 @@ const PFLAG_FORCE_LAYOUT = 1;
const PFLAG_MEASURED_DIMENSION_SET = 1 << 1;
const PFLAG_LAYOUT_REQUIRED = 1 << 2;
declare module "ui/core/view" {
export interface View {
_setNativeClipToBounds();
}
}
export class View extends ViewCommon {
private _hasTransfrom = false;
private _privateFlags: number = PFLAG_LAYOUT_REQUIRED | PFLAG_FORCE_LAYOUT;
@@ -397,11 +403,17 @@ export class View extends ViewCommon {
this.nativeView.backgroundColor = value;
} else {
this.nativeView.backgroundColor = ios.createBackgroundUIColor(this);
this._setNativeClipToBounds();
}
if (!updateSuspended) {
CATransaction.commit();
}
}
_setNativeClipToBounds() {
let backgroundInternal = this.style.backgroundInternal;
this.nativeView.clipsToBounds = backgroundInternal.hasUniformBorder() || backgroundInternal.getUniformBorderRadius() > 0;
}
}
export class CustomLayoutView extends View {

View File

@@ -3,11 +3,19 @@
export * from "./layout-base-common";
export class LayoutBase extends LayoutBaseCommon {
get [clipToBoundsProperty.native](): boolean {
return this._nativeView.clipsToBounds;
return false;
}
set [clipToBoundsProperty.native](value: boolean) {
this._nativeView.clipsToBounds = value;
this._setNativeClipToBounds();
}
_setNativeClipToBounds() {
if (this.clipToBounds) {
this._nativeView.clipsToBounds = true;
} else {
super._setNativeClipToBounds();
}
}
}

View File

@@ -164,7 +164,6 @@ function drawNonUniformBorders(nativeView: NativeView, background: Background) {
layer.borderColor = undefined;
layer.borderWidth = 0;
layer.cornerRadius = 0;
nativeView.clipsToBounds = true;
const layerBounds = layer.bounds;
const layerOrigin = layerBounds.origin;