Create a Custom Dialog in SwiftUI

preview_player
Показать описание
In this video you will learn how to create a custom dialog in SwiftUI.
I am building my video editing app and, I need a dialog to present before asking for permission to access photos. I could just use a regular Alert view, but since the photos dialog already looks like an alert, I thought that having a custom view would be a much better option here. So, I decided to create my own simple dialog 😊 

00:00 Intro
00:24 Apple Human Interface Guidelines
01:43 Project sketch
02:28 Build custom dialog
10:15 Add animation
14:02 Connect the dialog to a main view
16:32 Outro

#iOS #Swift #SwiftUI

Music: Streambeats
Рекомендации по теме
Комментарии
Автор

This is fantastic, works great and teaches good Swiftui concepts. Thank you

clayfulgham
Автор

Concise and informative. Love it. Thank you!

gojamesgo
Автор

Super useful as usual. Thanks for the video Mike! 🙌

jswallez
Автор

Great video! One can simplify code for xmark (10:11) by using overlay with topTrailing alignment. This would eliminate VStack, HStack and Spacers.

maqusss
Автор

How to present custom dialog over a sheet in SwiftUI such that you shouldn't be able to interact with the sheet?

acecala
Автор

For anyone looking to use this on your views, another way is to just change the same view to a ViewModifier and show with a transition using modifier

ncba
Автор

Pretty awesome tutorial. A couple of issues I have ran into though are, :
The alert always appears when the view is first loaded, and cannot be re-shown once dismissed. Simply removing onAppear and replacing with onChange(of: isActive) and used an if statement fixed that.
The other issue is that using ZStack does in fact allow me to click on the background to dismiss it, and even looks cool (by making everything else look inactive) but everything else IS inactive and remains inactive or un-clickable even after the popup is dismissed, and that issue I am still looking for a solution.

iceshadow
Автор

All this time I thought apple was using secret code to make those cute modal overlays. they were just hiding the views???

kayboy
visit shbcf.ru