I'm following this example to set the value of a button icon with an image (PNG file).
It works fine except that I can't find how the image can be set without border nor background. I tried to play with the setStrokeColor
and setFillColor
without success.
In that particular example one can simply remove the code which is used for adding the background and the border:
canvas.
saveState().
setStrokeColor(modelButton.getBorderColor()).
setLineWidth(1).
rectangle(0, 0, occupiedArea.getBBox().getWidth(), occupiedArea.getBBox().getHeight()).
stroke().
setFillColor(modelButton.buttonBackgroundColor).
rectangle(0.5f, 0.5f, occupiedArea.getBBox().getWidth() - 1, occupiedArea.getBBox().getHeight() - 1).
fill().
restoreState();
Please comment that line. I've also changed the used jpg image to a png one and that's what I've got as a result:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.