SwiftUI Inner Shadows + Core Motion = Beautiful and Easy Depth Effect!

preview_player
Показать описание
SwiftUI for iOS 16 introduces the ability to create inner shadows for icons, text, and more, and if we add just a little Core Motion we can create a beautiful depth effect that adjusts our shadow as the user tilts their device – it's easier than you might think!

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

I love combining it with the 3d rotation

danielcrompton
Автор

You forgot to say, that CMMotionManager by default uses CMMotionReferenceFrame where Z vector is vertical instead of Y, it means that with your code you should always hold a device parallel to the ground as you do in your video, otherwise rotating view will behave with bugs, but in real user experience nobody will hold device like that, so you must change your calculations to have true initial attitude.

TonyMontana-wsyc
Автор

Another fantastic video - thanks Paul! Great to have the warnings laid out so clearly to help avoid pitfalls. :-)

CraigSchubert
Автор

those modifiers are a separate great part to learn and play with

MrMassmaker
Автор

An easy and cool fix for "slow" motion updates is to put a linear animation modifier on the view :) It's actually hard to notice that the updates are much slower than the refresh rate.

excore
Автор

Yes! You did it! Thank you for posting it, Paul

daniel.iosdev
Автор

Blimey, things are really getting interesting with SwiftUI. Thanks Paul.

chrispyk
Автор

Wicked cool stuff Paul! Love your enthuasium for all things Swift/UI. I am working on a sports app that has NFL helmets on screen which will benefit from this cool effect. Thanks for sharing!

KimbrellBrad
Автор

@0:44 Sir Jony would have hated that, I am afraid… ;-)

Dear Paul, thank you so much (!!!) for making use of more demanding APIs in combination with SwiftUI. I have been waiting quite a while for examples like that ;-)

anotherguycalledsmith
Автор

This is genius! Your videos are amazing! Thank you so much, Paul!

karinaschreiber
Автор

hi paul, can you do video on how to add admob to swiftui??

saraboy
Автор

I'm trying to figure out how to identify if my phone is tilting forward (towards the ground) or backward (towards the ceiling) while in landscape orientation, using accelerometer or gyroscope.

At first, I thought the z-axis will show that i.e. +z means phone is tilting forward and - z means phone is tilting backward. However, when I console log z values, there doesn't seem to be a direct relationship with +/ - values and which way the phone is tilting. Does anyone know how to determine phone direction using accelerometer or gyroscope values? Or is there another way to go about this? Thank you.

sebastianmolina
Автор

Hi, do you think iOS development is good if I want to be freelancer?

ShredzZ
Автор

huh, i had no idea you could use a ipad to have your preview/build run externally, does it only work on ipad?

leonstone
Автор

Would we need extra code to disable the effect if users have ‘reduce motion’ activated or will SwiftUI take care of that automatically?

TheMisterGege
Автор

do we need new swift ui tutorials after the wwdc 2022 ? or last year still relevant?

flat-line
Автор

Wonderful, as always in all your videos and teachings. Although your explanation has a small flaw, my imagination... hahaha. Definitely, us backend developers are not that bright, I love Swift server side but I do want to keep learning SwiftUI.

OttoSchmilinsky
Автор

One more thing you could've done is to remove @Published and invoke objectWillChange.send manually on update.

aleksandarmilic
Автор

Yup everybody know u r a scammer bro :)

acbcsinister
Автор

Hey Paul! I think it would be nice to our community to have a Discord server, what do you think?

ASGSeven