Comments (6)
Rendering a GeometryReader
as a background
of the Button
and making the popover
a modifier of a Spacer
in the GeometryReader
and setting its excludedFrames
to contain the GeometryReader
's frame
in the .global
coordinate space did the trick for me
Button("Present popover!") {
present.toggle()
}
.background(
GeometryReader { geometry in
Spacer()
.popover(present: $present, attributes: { attributes in
attributes.dismissal.excludedFrames = {
return [geometry.frame(in: .global)]
}
}, view: {
Text("Hi, I'm a popover.")
})
}
)
from popovers.
Button("Present popover!") {
present.toggle()
}
.allowsHitTesting(!present)
.popover(present: $present) {
Text("Hi, I'm a popover.")
}
😂
from popovers.
I have found that using the following works for me.
This will dismiss the popover by tapping outside
$0.dismissal.mode = .tapOutside
I have also set an auto dismissal like this: You would attach this onAppear to the popover view
.onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: { showPopoverHint.toggle() }) }
All this works for me.
from popovers.
This needs to be a lib function but thank you for the creative solution!
from popovers.
Nice idea and fix, thanks. Will see what I can do
from popovers.
Unfortunately I can't find a working solution for accomplishing this with List items and popovers activated by selection, because List first removes the selection before adding it again. I'm now doing it by detecting extremely quick close/reopen on the same item.
from popovers.
Related Issues (20)
- How to make tap outside only dismiss the popover? HOT 1
- Example: Conflict with `UIKit` Name with Xcode 15/iOS 17
- Scroll not supported inside Templates.Menu?
- Is it possible to disable the ability to drag the popover on the screen? HOT 1
- Possible retain cycle on UIKit menu? HOT 4
- I cannot change color or add frame to image or text in Menu in style !
- Finding an element in popover during ui testing.
- Menu not work correctly with RTL Language
- Popover inside Scrollview not supported? HOT 1
- Menu doesn't work on List objects
- New release date
- How to show popover within the View not Window ? HOT 1
- مهم نمط المطور
- Popover doesn't show sometime in LazyVstack or LazyVGrid
- how to dismiss popover when parent view will disappear HOT 3
- check mark in uikit
- want to use Templates.BackgroundWithArrow but can't because its initializer is internal
- Problem using a custom number picker as a .popover HOT 1
- Download Examples
- Download Examples on iPad
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from popovers.