How to create custom ViewModifiers in SwiftUI | Advanced Learning #1

Поделиться
HTML-код
  • Опубликовано: 30 ноя 2024

Комментарии • 60

  • @jordancalhouncom
    @jordancalhouncom Год назад +6

    I greatly appreciate how you build up to the extension and include self in the extension func for explanation before simplifying it. Helps understand what the language itself is doing so much more than if you just imediantely went to the final code

  • @RoshniParekh-h6x
    @RoshniParekh-h6x Год назад +2

    I am learning swiftUI by watching your all bootcamps, Every single video is very very useful👍, Thanks for covering all points.

  • @KimbrellBrad
    @KimbrellBrad 3 года назад +4

    Great start here! You also always pick the perfect music for your videos. Thanks!

  • @AZMerf
    @AZMerf 3 года назад +5

    Thank you for covering this. Even if I’ve used them before, I like your style and always learn something new.

  • @sols.2525
    @sols.2525 3 года назад +2

    Glad you're back Nick. Good start to a new series!

  • @midnightcoder
    @midnightcoder 2 года назад

    Best series on SwiftUI hands down

  • @penyt
    @penyt Год назад +1

    This is so helpful! I've seen tutorials on creating Custom TextField Styles using much harder codes, but instead I could have just used this! I also am able to create the same modifier for TextEditor where the TextField Styles don't apply. I am so happy I came across your channel from a random recommendation online =] Liked and Subbed!

  • @Notkdenben
    @Notkdenben 5 месяцев назад

    I am new to programming, especially with swift, but this was a very interesting and helpful topic as it better explains what swiftUI is going. I don’t think the topic was covered quite this deep, but this video plus the one covering view builders helped me understand a lot of what swiftUI is doing for us in the background.
    For instance, all modifiers are just functions that take in some parameter and return said modified view. And for the viewbuider video, I can now better grasp why so much of SwiftUI containers that hold views are just view builders.
    I’m not sure if that’s a perfect way to describe these concepts, but that’s sort of what I took away from them.

  • @Krafcik226
    @Krafcik226 2 месяца назад

    Amazing feature, super simple and reusable. Will definitely use it in my apps.

  • @indomitabletr1834
    @indomitabletr1834 2 года назад +1

    Hi Nick, you are awesome, Your teaching is amazing

  • @softcoder404
    @softcoder404 3 года назад +1

    I have been waiting for this video... thanks boss

  • @brucknerdevilliers
    @brucknerdevilliers 2 года назад

    Great video, thank you. I moved the ViewModifier struct to its own Swift file - works like a charm and shortens the View code.

  • @ConfidentlyRong-jo5yt
    @ConfidentlyRong-jo5yt 5 месяцев назад

    It may simple but it sure is powerful!

  • @sanchirmunkh-erdene6405
    @sanchirmunkh-erdene6405 3 года назад +2

    Good stuff!

  • @FabricioMTL
    @FabricioMTL Год назад

    Nick you are the best ♥️

  • @emdutt4012
    @emdutt4012 Год назад

    another awesome video ..

  • @sumeshvs8605
    @sumeshvs8605 3 года назад +5

    Although I already know how to create custom View modifiers. Still, I'm very eager to see how you presenting this

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      Haha hope you liked it. I hope some of the next videos will be more helpful lol

  • @philippegden9826
    @philippegden9826 3 года назад +4

    Hi Nick, Great that you’re back. Really looking forward to this series. Quick question - why do we use the ViewModifier vs just write an extension on View - much like you have done, but with the modifiers we want there?

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      Hey Philip! Honestly, that is a great question and I'm not really sure. But I do know that Apple's documentation says to do it with custom ViewModifiers. Maybe there's performance benefits?

    • @BatouOfNexus
      @BatouOfNexus 3 года назад

      @@SwiftfulThinking Just writing an extension on a view depends on using existing modifiers. Thus you still need the method that applies your modifications at the end of the day somewhere. This method needs a consistent interface that is reusable hence the protocol with the object you pass in.

  • @shahbokhari
    @shahbokhari 3 года назад +2

    Hello Dear Nick Sir, please make your SwiftUI Videos 4K resolution. They are more pleasing to the eyes in the 4K displays. Besides, your contents are really helpful and so are your courses. Thank You

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +2

      I thought these were uploading 4K 😭 I'm going to figure this out, sorry!

  • @froggy58400
    @froggy58400 2 года назад

    Awesome video! Thank you so much 🙏

  • @danielwatson6529
    @danielwatson6529 3 года назад +1

    any idea how to do this with Images? I kept getting weird stuff like this "Instance member 'resizable' cannot be used on type 'Image' "

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад +1

      You can't do this directly with an Image because by protocol definition ViewModifier has to be applicable to any View. However, you can create extensions of Image directly, something like:
      extension Image {
      func myModifier() -> some View {
      self
      .resizable()
      }
      }

  • @Максим-ш7х4й
    @Максим-ш7х4й 3 года назад +2

    Thank you so much bro) explained cool

  • @josemanuelortizsanchez4983
    @josemanuelortizsanchez4983 2 года назад

    Good video, thanks!

  • @m__link6499
    @m__link6499 3 года назад +1

    Nick, why use the extension while the custom modifier always do the same thing 🤔? thank you,

    • @sols.2525
      @sols.2525 3 года назад +1

      I believe it is so you can get rid of having to use .modifier and passing in the func. Instead you can just call the extensions function.

  • @HolographicKode
    @HolographicKode Год назад

    I assume you can just skip creating the func version and just go with the extension alone (e.g. move the modifiers form the function into the extension).

  • @neneqixia4773
    @neneqixia4773 3 года назад +1

    The video is great🥳

  • @stolenhen
    @stolenhen 3 года назад

    great video!

  • @ABNERJUDE
    @ABNERJUDE Год назад

    Hi Nick, I'm an avid follower of viewing your SwiftUI tutorials. I'm a beginner and I'm moving on to watching your tutorials for me to learn as much as I could. When you have the chance, could you make one tutorial of a Mask ViewModifier wherein hundreds of small pieces of Rectangle-shapes acting as masks to dissolve any Image or Shapes? Thank you very much for your time and to all your video tutorials!

    • @SwiftfulThinking
      @SwiftfulThinking  Год назад

      Does this help: ruclips.net/video/pxx1ueCbnls/видео.html

    • @ABNERJUDE
      @ABNERJUDE Год назад

      @@SwiftfulThinking I'll check that out and see how I could implement those techniques you've presented in that Mask tutorial, to the View that I had in mind. Thanks!

    • @ABNERJUDE
      @ABNERJUDE Год назад

      @@SwiftfulThinking Hi Nick, I know that creating a ViewModifier requires a function or method in it --- func body (content: Content) --> some View. Can I embed another function/method within this? If yes, please show me how. I'll appreciate so much your response. Thanks!

  • @emadisaac7052
    @emadisaac7052 2 года назад

    Man you're a Legend , I want to ask can you do a complete Complex App like Uber . thanks for your effort

  • @selvarajant
    @selvarajant 2 года назад

    Awesome

  • @AdjieSatryo
    @AdjieSatryo Год назад

    Thank you, really aprreciated

  • @tokero5199
    @tokero5199 7 месяцев назад

    I liked the video but I find this example (of a button) would be better implemented as a custom view...

  • @TMT-ii3ro
    @TMT-ii3ro 2 года назад

    thanks for lecture

  • @rinotheone6806
    @rinotheone6806 Год назад

    sanks bro!

  • @prasadreddy878
    @prasadreddy878 3 года назад

    Bro please do video on Extensions

    • @SwiftfulThinking
      @SwiftfulThinking  3 года назад

      Haha I didn't think they needed a separate video. It's just an extension of a class or struct that we can then put anywhere in our code!

  • @guoweiyang5894
    @guoweiyang5894 2 года назад

    Thank you som much ,, can you post the github address links about these course coding examples so that I can download to learn

  • @magedmohmed4403
    @magedmohmed4403 Год назад

    I like a new Music 😂

  • @bryceellis112
    @bryceellis112 Месяц назад

    My app is about to get a major refactoring!

  • @loucadufault6549
    @loucadufault6549 Год назад

    Video starts @ 7:35
    Also 1.5x speed

  • @StianF
    @StianF 9 месяцев назад

    Honestly, unwatchably slow. "Advanced learning", spending more than four minutes on creating a new project, then spend five minutes explaining why it's a bad idea to copy and paste the same code over and over. This video should have started at 9:15 and ended at 9:30, skipped to 12:30, then just end at 13:00. Nothing before or after that had any value whatsoever and was 100% a waste of time. Also, no need to remove the font, just override it by putting it after the modifier if necessary. This video being 19 minutes was a robbery of time, yours and ours.