想动态生成一张分享的海报,看到了plus.webview.draw方法就试了一下,在安卓下正常,但在ios设置的截屏区域好像没有效果,默认截了全屏,请问有解决方法吗?还是我操作不当...
window.drawIMG = function(t, info, cb){
var wa = null;
if(t === 1) wa = 'poster-goods.html';
else if(t === 2) wa = 'poster-album.html';
else if(t === 3) wa = 'poster-app.html';
if(!wa) return false;
var bitmap = new plus.nativeObj.Bitmap('poster');
var w = plus.webview.create(wa, 'page-draw', {
backButtonAutoControl: 'close',
height: '450px',
// subNViews: [{
// id: 'drawNView',
// styles: {
// top: '10px',
// left: '5px',
// height: '310px',
// width: '310px'
// },
// tags: [{
// id: 'drawBG',
// tag: 'img',
// src: info.mainPic,
// sprite: {height: '100%', width: 'auto'}
// }]
// }]
}, {extras: info});
w.addEventListener('loaded', function(){
setTimeout(function(){
w.draw(bitmap, function(){
var t = new Date().getTime();
bitmap.save('_doc/poster/poster' + t + '.jpg', {quality: 100}, function(e){
if(cb) cb(e.target);
plus.nativeUI.closeWaiting();
bitmap.clear()
}, function(e){
console.log(e.message)
})
}, function(e){
console.log(e.message)
}, {
check: true,
clip: {top: '0px', width: '320px', height: '200px'}
})
}, 1000)
})
}
2***@qq.com
完美解决 赞
2022-03-08 18:15