diff --git a/lib/pen.js b/lib/pen.js index 7b79ed1..31dae80 100644 --- a/lib/pen.js +++ b/lib/pen.js @@ -75,7 +75,10 @@ export default class Painter { _doBorder(borderRadius, width, height) { if (borderRadius && width && height) { const r = Math.min(borderRadius.toPx(), width / 2, height / 2); - this.ctx.setFillStyle("rgba(0, 0, 0, 0)"); + // 防止在某些机型上周边有黑框现象,此处如果直接设置 setFillStyle 为透明,在 Android 机型上会导致被裁减的图片也变为透明, iOS 和 IDE 上不会 + // setGlobalAlpha 在 1.9.90 起支持,低版本下无效,但把 setFillStyle 设为了 white,相对默认的 black 要好点 + this.ctx.setGlobalAlpha(0); + this.ctx.setFillStyle("white"); this.ctx.beginPath(); this.ctx.arc(-width / 2 + r, -height / 2 + r, r, 1 * Math.PI, 1.5 * Math.PI); this.ctx.lineTo(width / 2 - r, -height / 2); @@ -92,6 +95,7 @@ export default class Painter { getApp().systemInfo.platform === 'ios')) { this.ctx.clip(); } + this.ctx.setGlobalAlpha(1); } }