How to get rounded corners on an Electron app?

北城余情 提交于 2021-02-18 22:13:46

问题


I am currently trying to get rounded corners on an Electron application I'm making. I have tried nearly every solution available on-line at the moment, but none of them make any difference.

How can I round the corners of my Electron app?


回答1:


Make a frameless transparent window

const myWindow = new BrowserWindow({
    transparent: true, 
    frame: false
})

And have something like this in the renderer, or apply the style directly to the body tag

<div style="width: 500px; height: 500px; border-radius: 5px">My window content</div>

Just make sure to also add a custom window titlebar that has -webkit-app-region: dragin order to make the window dragable from this element.

Check out the Electron Docs for further informations ;) https://github.com/electron/electron/blob/master/docs/api/frameless-window.md#transparent-window



来源:https://stackoverflow.com/questions/51262645/how-to-get-rounded-corners-on-an-electron-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!