How to create resizable sheets in SwiftUI | Bootcamp #64

Swiftful Thinking
8 Jun 202315:13

Summary

TLDR在这段视频脚本中,Nick 介绍了 iOS 16 中新增的一个功能——可调节大小的弹出层(sheet)。在 iOS 16 之前,弹出层的大小是固定的,只能覆盖屏幕的一部分。但 iOS 16 引入了新的 API,允许开发者创建可调节大小的弹出层,这意味着弹出层可以是半屏、四分之一屏或任何自定义大小。Nick 展示了如何通过简单地添加一行代码,使用现有的弹出层 API 来实现这一功能。他创建了一个名为 'resizableSheetBootCamp' 的 SwiftUI 视图,并演示了如何通过设置不同的 'presentation detents' 来控制弹出层的大小。此外,还介绍了如何通过编程方式在不同的弹出层大小之间切换,以及如何禁用交互式解散,以创建一个用户无法通过下拉关闭的弹出层。这个新功能为 Swift UI 开发者提供了更多自定义界面的可能性,使得 UI 设计更加灵活和丰富。

Takeaways

  • 📱 iOS 16 新增了可调整大小的sheet功能,允许开发者创建不同尺寸的sheet。
  • 🔄 与iOS 16之前的sheet相比,新功能不会全屏覆盖,而是可以根据需要调整大小。
  • 💡 API与现有的sheet API完全兼容,开发者只需添加一行代码即可实现自定义尺寸的sheet。
  • 📈 通过`presentation: detents`,开发者可以指定sheet的大小,如中等(medium)或大(large)。
  • 🔗 可以使用`@State`变量来绑定和控制sheet的尺寸,实现程序化地在不同尺寸间切换。
  • 🚫 新增的`interactiveDismissDisabled`修饰符可以禁用sheet的滑动关闭功能,适用于需要强制用户完成某些操作的场景。
  • 🔽 用户仍然可以通过向下滑动来关闭sheet,这是Swift UI中sheet的一个通用特性。
  • 🎨 可以使用分数(fraction)和高度(height)来创建自定义尺寸的sheet,以适应不同的设计需求。
  • 📐 推荐使用分数而非固定高度,因为分数可以更好地适应不同尺寸的屏幕。
  • 🧩 可以在同一个`presentation: detents`中组合多种尺寸,提供更丰富的交互体验。
  • ⚙️ 需要注意的是,只能设置在`presentation: detents`修饰符中定义的尺寸,否则会导致错误。

Q & A

  • iOS 16 中新增的可调整大小的sheet功能是什么?

    -iOS 16 新增的可调整大小的sheet功能允许开发者创建可以调整大小的界面元素,这些元素可以是半屏、四分之一屏或者任何自定义大小。这个功能与现有的sheet API完全兼容,开发者只需在现有代码中添加一个新的modifier即可实现。

  • 如何使用Swift UI在iOS 16中创建一个可调整大小的sheet?

    -在Swift UI中,你可以通过给`sheet`添加一个`presentation: detents` modifier来创建一个可调整大小的sheet。这个modifier接受一个包含不同大小的集合,例如`.medium`和`.large`,或者自定义的尺寸如分数或固定高度。

  • 在iOS 16之前,sheet的界面元素是如何的?

    -在iOS 16之前,sheet的界面元素通常是全屏的,它覆盖了整个屏幕,没有提供半屏或四分之一屏等中间尺寸的选择。

  • 如何使用Swift UI实现一个始终显示在屏幕上的sheet?

    -通过给sheet添加`interactive dismissal disabled` modifier,可以创建一个始终显示在屏幕上的sheet,用户无法通过拖动来关闭它。这适用于需要用户完成某些操作(如支付)才能继续使用应用的场景。

  • 如何自定义sheet的大小?

    -可以通过设置`presentation: detents` modifier中的不同detents来自定义sheet的大小。可以使用预设的如`.medium`和`.large`,或者使用自定义的分数(如`0.5`代表屏幕的一半)和固定像素高度(如`200`像素)。

  • 如何通过编程方式在不同的sheet大小之间切换?

    -可以通过创建一个绑定到`presentation detents`的变量,并在需要的时候更新这个变量的值来在不同的sheet大小之间切换。例如,可以创建两个按钮,一个设置为`.medium`,另一个设置为`.large`,通过点击这些按钮来改变sheet的大小。

  • 为什么在尝试添加一个不在`presentation detents` modifier中定义的detent时会出错?

    -如果尝试添加一个不在`presentation detents` modifier中定义的detent,程序会报错,因为Swift UI只允许设置在modifier中已经定义的detents。因此,如果计划在代码中动态设置detents,需要确保这些detents已经在modifier中声明。

  • 如何隐藏sheet的拖动指示器?

    -可以通过设置`presentation drag indicator`为`hidden`来隐藏sheet的拖动指示器。这在自定义拖动指示器或者不希望显示拖动指示器的情况下很有用。

  • 用户如何与可调整大小的sheet进行交互?

    -用户可以通过拖动来调整sheet的大小,或者通过swipe down来关闭sheet。此外,开发者可以提供按钮或其他UI元素,允许用户通过点击来改变sheet的大小。

  • 为什么说iOS 16中的这个新API对Swift UI开发者来说是一个巨大的胜利?

    -这个新API允许开发者以极少的代码更改实现复杂的、可自定义的界面元素,如可调整大小的sheet,而无需从头开始构建自定义的拖动手势,这大大简化了开发工作并提高了开发效率。

  • 在iOS 16中,如何实现一个初始状态为特定大小的sheet,并允许用户进一步调整其大小?

    -可以在创建sheet时设置一个初始的`presentation detent`,然后通过`presentation: detents` modifier提供一系列用户可以拖动到的大小。用户可以通过拖动来调整sheet的大小,或者使用提供的UI元素来切换到预设的大小。

Outlines

00:00

📱 iOS 16 新特性:可调整大小的弹出层

iOS 16 引入了一个令人兴奋的新特性,即可以创建可调整大小的弹出层(sheets)。与 iOS 16 之前的版本相比,弹出层不再局限于屏幕顶部,而是可以根据需要调整为任意大小,如半屏或四分之一屏。这个新特性的亮点在于,开发者可以使用现有的弹出层 API,仅需添加一行代码和一个新修饰符(modifier),即可实现这一功能。视频中,Nick 展示了如何通过 Swift UI 实现这一特性,并创建了一个简单的示例,通过一个按钮触发弹出层,并展示了如何使用 `presentation detents` 来控制弹出层的大小。

05:01

🔍 自定义弹出层大小与交互

视频的第二部分深入探讨了如何自定义弹出层的大小和交互方式。Nick 介绍了如何使用 `presentation detents` 来设置弹出层的不同大小,包括中等(medium)、大(large)以及自定义的分数值(如 0.5 代表屏幕的一半)。此外,还展示了如何通过编程方式在不同的弹出层状态之间切换,以及如何使用 `interactive dismiss disabled` 修饰符来禁用弹出层的滑动关闭功能,这在某些特定场景下非常有用,比如用户必须完成某些操作才能继续使用应用。

10:02

🛠️ Swift UI 开发者的新工具:绑定选择与动态交互

在视频的最后部分,Nick 展示了如何使用 `@State` 变量来绑定和控制弹出层的大小,使得开发者可以创建按钮来在中等和大尺寸的弹出层之间动态切换。此外,还提到了在自定义弹出层大小时需要注意的一些限制,例如只能在 `presentation detents` 修饰符中预定义的尺寸中进行选择。最后,Nick 强调了这一新特性对于 Swift UI 开发者来说是一个巨大的胜利,因为它简化了自定义拖动手势的实现,并且提供了流畅的用户体验。

Mindmap

Keywords

💡iOS 16

iOS 16是苹果公司最新发布的移动操作系统版本。在视频中,它被提及为引入了可调节大小的sheet(视图)功能,这是iOS 16中一个重要的更新,允许开发者创建不同大小的视图,从而提供更丰富的用户界面体验。

💡Sheet

Sheet是Swift UI中的一个组件,用于在屏幕上显示模态内容。在iOS 16之前,sheet的大小是固定的,不能调整。视频中提到,iOS 16的新特性允许开发者通过编程方式改变sheet的大小,从而提供更灵活的界面设计。

💡Swift UI

Swift UI是苹果公司推出的一种用于iOS、iPadOS、macOS、watchOS和tvOS应用程序的UI工具包。它允许开发者使用Swift语言创建用户界面。视频中,Swift UI被用来展示如何利用iOS 16的新特性创建可调节大小的sheet。

💡Presentation Detents

Presentation Detents是iOS 16中新引入的一个概念,用于定义sheet可以呈现的不同大小。在视频中,通过设置presentation detents,开发者可以指定sheet在不同状态下的大小,如中等、大或自定义的百分比大小。

💡API

API(应用程序编程接口)是一套预先定义的函数,允许不同的软件应用程序之间进行交互。视频中提到,iOS 16的API与现有的sheet API兼容,这意味着开发者可以使用现有的代码,仅需添加少量代码即可实现新的功能。

💡Fraction

在视频中,fraction用于表示sheet大小占屏幕比例的一个数值。例如,0.5表示sheet将占据屏幕的一半。这是创建自定义大小sheet的一种方式,允许开发者根据需要灵活地调整界面元素。

💡Drag Indicator

Drag Indicator是用户界面中的一个视觉元素,用来指示用户可以通过拖动来调整界面元素的大小或位置。在视频中,提到可以通过设置来隐藏或显示drag indicator,这取决于是否希望用户能够通过拖动来调整sheet的大小。

💡Interactive Dismiss

Interactive Dismiss是指用户可以通过交云操作来关闭或解散某个界面元素的功能。在iOS 16中,新的modifier允许开发者禁用这个功能,使得sheet不能通过向下拖动来解散,这在某些特定的应用场景下非常有用,比如支付墙或免费试用结束时。

💡Custom Detents

Custom Detents允许开发者为sheet定义自定义的大小。在视频中,除了使用预设的如medium和large,开发者还可以通过fraction和height来创建任意大小的sheet,从而提供更加个性化和多样化的用户体验。

💡Binding

Binding是Swift UI中的一个特性,它允许将UI元素的状态与数据源关联起来,以便在数据变化时自动更新UI。在视频中,通过binding来动态改变sheet的presentation detents,从而在不同的视图或按钮点击事件中调整sheet的大小。

💡Swiftful Thinking

Swiftful Thinking是视频中提到的频道或品牌名称,由Nick主持,专注于Swift UI和iOS开发的教学。视频中通过Swiftful Thinking介绍了iOS 16中sheet的新特性,展示了如何利用这些特性来提升应用程序的用户体验。

Highlights

iOS 16 引入了可调整大小的sheets功能,这是iOS 16中最受欢迎的新特性之一。

在iOS 16之前,sheets只能弹出到屏幕顶部,不能全屏覆盖。

iOS 16的新modifiers允许开发者自定义sheets的大小,如半屏或四分之一屏。

API与现有的sheets API完全兼容,只需添加一行代码即可实现自定义sheets。

许多应用程序开始采用这种新的sheets设计,如半屏模态框。

通过Swift UI,开发者可以用一行代码实现这些新的sheets功能。

创建一个名为'resizableSheetBootCamp'的新Swift UI视图文件。

使用@State属性控制sheets的显示,初始值为false。

通过添加presentation modifier来控制sheets的大小。

使用detents来定义sheets的大小,如large和medium。

可以拖动sheets在不同的detents之间切换,提供流畅的用户体验。

可以使用presentation drag indicator隐藏或显示拖动指示器。

sheets支持向下滑动以解散,但新modifier可以禁用交互式解散。

可以完全自定义sheets的detents,包括使用fraction和height。

fraction允许根据屏幕的百分比来设置sheets的大小。

height允许根据像素值来设置sheets的大小。

可以组合使用不同的detents,如fraction、height和预设的medium或large。

可以使用编程方式在不同的detents之间切换,增加交互性。

需要注意的是,只能设置在presentation detents modifier中定义的detents。

modifiers可以放置在destination view的任何部分,以实现更清洁的布局。

iOS 16的sheets功能为Swift UI开发者提供了巨大的便利,使得自定义UI变得更加容易。

Transcripts

play00:00

all right guys this is probably my

play00:02

favorite thing to come out of iOS 16. if

play00:05

you're not using this yet you should

play00:07

probably restart uh iOS 16 gives us the

play00:09

ability to create sheets that are

play00:12

resizable so prior to iOS 16 we

play00:15

basically had one sheet that could pop

play00:17

up and if you ever use that sheet

play00:18

modifier you would see that it goes

play00:20

basically to the top of the screen it's

play00:22

not a full screen cover so it doesn't

play00:24

cover the entire screen but it goes

play00:26

basically to the top like right to the

play00:28

safe area at the top of the screen

play00:30

however now that we have these iOS 16

play00:32

modifiers we can actually change the

play00:34

size of that sheet so we can do like a

play00:37

half screen sheet a quarter screen sheet

play00:39

basically literally any size that we

play00:41

want we can now do and my favorite part

play00:43

of the feature is that literally the API

play00:46

works perfectly with the existing sheet

play00:49

API so we can use our existing code and

play00:53

literally just add one new line of code

play00:54

one new modifier and all of a sudden we

play00:57

have this magic customizable sheet it's

play01:00

really awesome to use I've definitely

play01:01

seen a lot of apps these days starting

play01:04

to shift more towards this so if you use

play01:07

an app where like a sheet comes up about

play01:09

halfway that's exactly what we're

play01:11

talking about and now we can do it in

play01:12

Swift UI with literally one line of code

play01:22

[Music]

play01:24

welcome back everybody my name is Nick

play01:27

this is swiftful thinking in this video

play01:29

we're going to cover the resizable sheet

play01:32

I think this is my favorite thing to

play01:35

come out of iOS 16. thank you Apple for

play01:38

releasing this API let's take a look at

play01:41

it we're going to right click the

play01:42

Navigator create a new file it is a

play01:44

swift UI View and let's call this

play01:46

resizable

play01:48

cheat boot camp

play01:51

click create let's jump in here get the

play01:54

canvas working

play01:55

and we are going to start with a very

play01:58

simple screen in this one a quick button

play02:00

with a title says click me of course and

play02:06

we're gonna up here create an at State

play02:10

private VAR show sheet of type Bool set

play02:14

it equal to false

play02:16

in here we're going to call

play02:18

showsheet.toggle we're going to add a

play02:20

very simple sheet with is presented

play02:23

is presented bind to that Boolean and

play02:26

then adds some content and I'm just

play02:28

going to come down here and create a

play02:30

struct called my next View

play02:34

which will be a view a review needs a

play02:37

body I'm just going to put a quick maybe

play02:40

a text here that says hello world

play02:46

uh the destination will be my next View

play02:49

and this should not be something that is

play02:51

new to you guys I've covered sheets in

play02:54

this playlist I think we used it in a

play02:56

bunch of videos already did literally an

play02:58

entire where is it

play03:01

sheet boot camp we did a whole sheets

play03:03

bootcamp looked at full screen cover and

play03:06

sheet but up until iOS 16 the sheet only

play03:10

only allowed us to do this one sheet so

play03:13

we can see here that the sheet goes up I

play03:15

would say probably about you know 90

play03:18

percent of the way to the screen the

play03:20

full screen cover goes all the way to

play03:21

the top but there was no way to do a

play03:24

sheet that's like half screen or like

play03:26

quarter screen or something like that

play03:27

iOS 16 though allows us to do these

play03:30

custom basically any size sheet we want

play03:32

not just this full screen sheet and the

play03:36

really cool feature about this is that

play03:39

it is 100 compatible with this existing

play03:42

modifier so in my app if I already have

play03:44

this modifier of sheet I don't need to

play03:47

change that at all all I need to do is

play03:49

just add an extra modifier onto the

play03:52

destination view here

play03:54

so what I'm going to do is call on this

play03:56

I'm just going to add a DOT presentation

play03:59

detents

play04:01

detents are basically the sizes of the

play04:04

sheet that we want it to go to there's

play04:06

two completions here I'm going to start

play04:07

with this basic one and it looks like

play04:09

it's a set of presentation detent if now

play04:13

if you're just learning Swift in this

play04:14

boot camp you probably are not that

play04:15

familiar with the set a set is basically

play04:18

the same thing as an array except all

play04:21

the items are unique you can't have two

play04:23

of the same items in a set whereas an

play04:25

array you could have two of the same

play04:27

item and so here we're just going to

play04:29

create what looks like an array it's

play04:31

really a set and then inside this

play04:33

detents we need to tell it what sizes do

play04:36

we want this sheet to be able to resize

play04:38

to

play04:39

so we don't put any it's the default

play04:41

Behavior we can see it goes all the way

play04:42

up to here I'm gonna actually just make

play04:45

this screen have a background color

play04:47

let's do color dot red

play04:52

just so we can see this a little bit

play04:54

better

play04:55

so we can see the screen goes you know

play04:58

all the way up the full size of a screen

play05:00

so what is this this detent is actually

play05:03

called dot large so if I add in large

play05:06

here it allows me to go to this large

play05:08

state

play05:09

but if I wanted to go maybe halfway I

play05:12

could actually add in medium

play05:14

so a medium state allows it to literally

play05:17

go halfway which is this is like a very

play05:19

ideal use case in a lot of apps I think

play05:22

there's more and more we're starting to

play05:23

see these like half screen half modals

play05:25

and now we can do it out of the box in

play05:28

Swift UI with a medium detent

play05:31

something that's really cool about this

play05:32

is that this is an array or a set so we

play05:35

can actually add multiple in here so if

play05:36

I add in both of these I can actually

play05:38

then drag the sheet between these two

play05:42

detents which is really convenient so

play05:45

again if I take out the large I can't

play05:47

actually drag it up to that large state

play05:51

so we have total control over where can

play05:54

the user or can't the user drag it to

play05:57

when we add multiple of these you do see

play05:59

that little tab drag indicator that

play06:02

appears here so we have the option of

play06:04

calling presentation drag indicator

play06:07

hidden so if we want to hide it now so

play06:12

generally I would say if you are

play06:15

allowing the user to drag it you should

play06:17

show the drag indicator unless you're

play06:20

building like maybe you want to draw

play06:21

your own drag indicator that looks a

play06:23

little bit better obviously you can do

play06:25

that as well

play06:27

one thing that is pretty cool on sheets

play06:29

in general is that the user can swipe

play06:31

them down to dismiss right so even with

play06:34

the old sheet you'll be able to swipe it

play06:36

down and it goes away

play06:37

but we have this new modifier that

play06:40

actually allows us to interactive

play06:41

dismiss disabled which allows us to show

play06:45

a sheet and then the user is not allowed

play06:47

to actually drag it down

play06:50

and if you've never seen this before you

play06:51

might be thinking like why on Earth

play06:52

would I ever want to do that well you

play06:54

could imagine an app where maybe like

play06:56

the

play06:57

maybe the paywall or like the free trial

play07:00

screen appears and the user is not

play07:02

allowed to get back into your app until

play07:04

they complete some action or do a

play07:07

payment and so this is a perfect use

play07:09

case where we can show a sheet and

play07:11

literally have it like stuck on the

play07:13

screen

play07:14

I think like this would be a major tease

play07:17

if you had like your actual app running

play07:20

back here and then you did something to

play07:21

trigger the sheet and then put this

play07:24

interactive dismiss disabled so now the

play07:26

user is like this close into your app

play07:28

but they actually can't do anything

play07:30

because the sheet is showing and they

play07:31

can't dismiss it until they make a

play07:34

purchase that would be like

play07:36

the biggest tease you could possibly

play07:38

have in your app

play07:39

definitely a lot of use cases for this

play07:41

even if you're not thinking of them

play07:43

right now

play07:44

before we wrap up let's look at a couple

play07:46

more custom detents so of course we have

play07:48

the medium we have the large but we can

play07:50

also just totally customize our own

play07:52

detents to any size that we want

play07:55

I'm just going to do it on another line

play07:56

here let's just do a DOT presentation

play07:58

detents and this time I'm going to look

play08:01

for there's a fraction and a height

play08:03

so a fraction is basically like a

play08:06

percentage of the screen I don't know if

play08:08

it's exactly a percentage of the screen

play08:10

but it's more or less the same so for

play08:13

example if I do 0.5 that would be about

play08:16

50 of the screen very similar to a

play08:19

medium not exactly the same I could do

play08:21

maybe 0.75 now we're up here I'm gonna

play08:24

do 0.9 getting close to the top I can do

play08:28

0.1 down towards the bottom so this

play08:31

might be like a really cool you know if

play08:33

you want to just show a little something

play08:35

at the bottom and then maybe have the

play08:37

user able to like drag this up

play08:39

you could have a fraction of 0.1 and

play08:41

then also have maybe a DOT medium and a

play08:44

large right so we could do something

play08:46

like on a pure right where we

play08:49

automatically

play08:51

trigger the show sheet equals true

play08:54

so your app starts with his little sheet

play08:56

popped out here and then the user can

play08:58

then like drag it a little bit bigger

play09:00

drag it a little bit bigger and also

play09:02

close it down or something like that we

play09:05

get really customizable with some of

play09:06

this we can also do as I was saying

play09:09

before the presentation detents of a DOT

play09:12

height height is how many pixels do we

play09:15

want it to be so we could do 200 pixels

play09:19

that's about 200 right there we could do

play09:22

800 pixels do 500 pixels generally I

play09:26

would say I would use the fraction in

play09:28

the medium large more than the height

play09:30

because the height you need to really

play09:32

understand

play09:33

the different screen sizes right some

play09:36

some devices have less height than

play09:38

others and you wouldn't want to make

play09:40

your sheet larger than like the screen

play09:42

device or something like that so a

play09:44

fraction is probably safer although like

play09:47

a certain UI if you have a specific

play09:49

element that's 300 pixels High then

play09:53

maybe the height makes more sense

play09:55

we can also obviously combine a bunch of

play09:57

these together so I could put this

play09:59

inside here and now we're using all of

play10:01

these in one same detent here we have

play10:04

like the the fraction of ten percent the

play10:07

height of about 300 the medium and then

play10:10

the large

play10:12

so really cool it's a really cool really

play10:15

smooth interaction here like if you were

play10:18

to build your own drag gesture on a

play10:20

screen it would take a lot of work to

play10:21

get to be this smooth so this is a huge

play10:24

win for Swift UI Developers

play10:27

and the last thing I want to show you

play10:29

guys is that other completion here with

play10:31

the dot presentation detents where we

play10:34

can basically bind to a selection

play10:40

so up here I'm going to put a at State

play10:43

private VAR let's call this detents

play10:47

of type

play10:49

and it looks like we need a presentation

play10:51

detent so presentation detent

play10:55

and we'll set it equal to dot large to

play10:59

start yeah we'll start with the large

play11:00

detent

play11:01

and for the detents let's just go back

play11:03

to medium and large

play11:06

and so before the user could drag

play11:08

between medium and large now they can do

play11:11

that and we can also programmatically

play11:13

shift between medium and large

play11:16

so here I have click me and we have

play11:19

Hello World maybe there's like a button

play11:22

on a screen that allows us to switch

play11:25

between the medium and the large so what

play11:28

I'm going to do is actually let's see

play11:30

let's take the detent and let's make a

play11:33

binding

play11:35

VAR let's call this detents of type

play11:38

presentation detent

play11:40

will bind to it on our second screen

play11:43

and now I just want to update these

play11:45

detents from the secondary screen so I'm

play11:48

just going to create in here like a

play11:49

v-stack

play11:51

maybe some spacing of 20. let's get rid

play11:53

of this and let's add in a button

play11:56

let's make this one the medium button

play11:58

and we'll set the detents equal to

play12:00

medium

play12:01

and let's just copy that we'll do a

play12:04

large button most of the detent is equal

play12:07

to large

play12:08

so now I'm going to click me and now we

play12:10

can programmatically go to a medium I

play12:13

can go to the medium State I can go to

play12:15

the large State I am noticing there's

play12:18

like a little bit of a like a glitch

play12:19

here when I shift down to the medium I

play12:22

am not exactly sure how to fix that at

play12:25

this time I'm sure that's not supposed

play12:28

to be happening

play12:30

so a couple things I want to note

play12:31

quickly is that in here we in theory

play12:35

could add any detent so we can add in

play12:37

maybe the fraction of 0.5 to these

play12:41

detents but when I click it and I go to

play12:44

medium it's not going to work so it kind

play12:46

of just broke and the reason it broke is

play12:48

because we're only allowed to set

play12:51

detents that we have set in our

play12:54

presentation detents modifier

play12:56

so it's something to be very careful of

play12:58

right like if we are going to add in

play13:01

this fraction here we should also make

play13:03

sure it's included in our array when we

play13:07

set up the modifiers click this

play13:10

and now it's working

play13:12

also these these modifiers they

play13:14

basically can be on any part of this

play13:16

destination view so I can also take

play13:18

these I'll just copy them and put them

play13:21

down on this view if like that's a

play13:22

little bit cleaner for you you're

play13:24

welcome to do that as well before we

play13:26

wrap up let's just add in maybe two more

play13:28

here I'm going to do a this will be that

play13:30

Medium

play13:32

this will be let's say maybe 20 percent

play13:37

fraction is 0.2

play13:39

and let's just do one more of maybe

play13:42

let's say 600 pixels

play13:45

and that will be of height 600.

play13:49

and again to make sure that these all

play13:50

work we need to make sure all of these

play13:52

cases are inside are right here so we

play13:55

have 0.2 medium we have height of 600

play13:59

and we have large

play14:01

there we go 20 medium 600 large awesome

play14:07

all right I I would argue this is the

play14:10

coolest thing to come out of iOS 16. let

play14:12

me know in the comments what you think

play14:13

of it I think there's like a lot of

play14:15

really cool UI that we can start doing

play14:17

especially with just like the medium

play14:19

detent I think it's cool that we can

play14:21

make our own custom bindings so if you

play14:23

use like I think like Lyft and Airbnb

play14:25

they have a lot of UI that kind of looks

play14:28

in this realm personally I think like

play14:31

the best part of it for me is purely the

play14:34

medium detent like if we can just do a

play14:36

sheet with just the medium detent

play14:38

especially if we can lock it that really

play14:41

opens us up to very easily putting some

play14:43

of these these modal sheets on the

play14:45

screen

play14:47

prior to iOS 16 if we want to do this UI

play14:49

we had to build it totally custom and

play14:51

that was a pain so thank you Apple for

play14:54

another awesome API in iOS 16.

play14:57

thank you guys for watching as always

play14:59

I'm Nick this is swifflethinking and

play15:01

I'll see you in the next video

play15:04

[Music]

Rate This

5.0 / 5 (0 votes)

Related Tags
iOS 16Swift UISheet自定义界面设计API交互编程用户体验开发者UI趋势
Do you need a summary in English?