Using SwiftUI .hoverEffect modifier on iPad causes doubling of visuals

Development / iOS / Making of Captionista
Screenshot of the ugly doubling effect you get when using hoverEffect

Another discovery on the trail to the Captionista release!

I thought I’d add .hoverEffect modifiers for the iPad UI to show the nice hover animations that iOS provides for pointing device users. Sadly, in SwiftUI this doubles up the visual of the buttons when focused. You move the pointer around and can see the lifted/translated version over the top of the original.

Read More

Sheets in SwiftUI on iPhone do not make the presenting view shrink behind

Development / iOS / Making of Captionista
Screenshot of modal sheet on iOS not shrinking the view behind

After solving the problem with SwiftUI adaptive popovers on iPad not dismissing properly on iPhone or in compact split view on iPad in Captionista, I noticed something…

If you show a modal sheet on iPhone, if you look closely you can see that the view behind does not shrink backwards as it would with a native UIKit modal presentation since iOS 13.

Read More

Are you seeing a weird change in text and image styles when you dismiss a SwiftUI popover?

Development / iOS / Making of Captionista

Another one from the “building Captionista” files, I noticed that on iPad any Text inside a popover that has no explicit font will change weight/size when the popover is dismissed, also affecting the layout. You only see it briefly when you tap away from the popover, but it looks bad!

Note that the same problem applies to imageScale so it looks like there is something in the environment that changes when the popover dismiss begins.

Workaround: Add .font(.body) or similar on the elements so you’re not relying on any defaults in the View hierarchy.

SwiftUI Popover replaces existing popover without moving it or pointing it at the correct view

Development / iOS / Making of Captionista

While building our new subtitling app Captionista we changed the UI to have a couple of buttons in the navigation bar that show popups on iPad.

I hit another fun bug with Popovers in SwiftUI: if you have multiple UI elements that can show a popover, if the user does not dismiss the previous popover, the next one will be shown in the previously active popover.

Unfortunately SwiftUI replaces the previous popover content but does not move the popover on iPad to point at the correct UI element, which is very bad.

Workaround: None that I know of yet.

There’s a feedback: FB8889229 “With SwiftUI, opening a new popover on iPad when the previous is still active, replaces the content of the old popover”