I want a window with a rounded corners. But I get a white spot in every corner.
Code:
let effect = NSVisualEffectView(frame: NSRect(x: 0, y: 0, width: 0, height: 0))
effect.blendingMode = .behindWindow
effect.state = .active
effect.material = .dark
effect.wantsLayer = true
effect.layer?.cornerRadius = 15.0
window.contentView = effect
window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
Output:
How to get rid of those white spot in the corners?
Make UIImageView Corners RoundedSetting the corner radius to 100 will make the image view completely rounded. Try different corner radius like 10, 20, 30, 40 to get image corners of different radius. To make the image border and visible I will set the borderWidth and the borderColor.
If you start with a regular UIView it has square corners. You can give it round corners by changing the cornerRadius property of the view's layer . and smaller values give less rounded corners. Both clipsToBounds and masksToBounds are equivalent.
To make an image with round corners or to make any view or button or any UI element with round corners in swift, we need to access the corner radius property of its layer. Every UI element in iOS is based on a layer. First of all, let's add an UIImageView Object in our storyboard. Or let's create one programmatically.
Also add this code to your code
window.isOpaque = false
window.backgroundColor = .clear
I don't have my machine to check but once I had the same issue and I think I resolved it by using above code. I will check when I get back to my machine.
Give it a shot and update me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With