How to get a view size in SwiftUI

  Рет қаралды 1,284

Mike Mikina

Mike Mikina

Күн бұрын

In this video, you will learn how to get the size of a view in SwiftUI, as well as how to update it when the size changes, and create a useful extension for it.
Link to the repository: github.com/mikina/GetViewSize...
00:00 Intro
00:26 Sample app
01:29 Add GeometryReader
02:10 The wrong way of using it
02:44 The best way
06:23 Use PreferenceKey
09:57 Create an extension
11:46 Outro
#iOS #SwiftUI #programming
Music: Streambeats

Пікірлер: 10
@user-yv9sh7id6i
@user-yv9sh7id6i 10 ай бұрын
Super useful! Thanks for sharing the tip. I think I'm going to copy your extension and then perhaps use a @Binding instead of having the closure.
@markaurelius61
@markaurelius61 10 ай бұрын
Very neatly done. I like the way you tidied it up in that modifier
@mikemikina
@mikemikina 10 ай бұрын
Thanks Mark!
@obrienserhii
@obrienserhii Ай бұрын
thanks!!!
@victorriurean
@victorriurean 3 ай бұрын
🔥
@vitorgomes4794
@vitorgomes4794 5 ай бұрын
First of all, thanks for sharing this content @Mike. Second, I did the same thing on my project, but there I am using a List, not a ScrollView, and my button actually are two buttons inside a VStack. I am using a GeometryReader on this two buttons VStack but when I add the variable to the List .padding modifier my buttons VStack creates a weird white stripe behind, starting in the middle of the buttons VStack and going to the bottom. Have you got this behavior?
@mikemikina
@mikemikina 5 ай бұрын
Not sure if I got this 🤔 Could you share a sample code?
@vitorgomes4794
@vitorgomes4794 5 ай бұрын
@@mikemikina Yes! How can share with you?
@mikemikina
@mikemikina 5 ай бұрын
You can create a Gist on GitHub or a regular repo. If you don't want to make it public, you can just add me to this repo. My GitHub handle is: "mikina."
@vitorgomes4794
@vitorgomes4794 5 ай бұрын
@@mikemikina It is the file pinned on my home page of GitHub. Sao Judas Tadeu Americana/Views/PrayersViews/NovenaView.swift, that's the file
SwiftUI: Environment property. You should use it!
7:43
Mike Mikina
Рет қаралды 692
A clash of kindness and indifference #shorts
00:17
Fabiosa Best Lifehacks
Рет қаралды 132 МЛН
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,6 МЛН
НРАВИТСЯ ЭТОТ ФОРМАТ??
00:37
МЯТНАЯ ФАНТА
Рет қаралды 7 МЛН
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 26 МЛН
Learn when SwiftUI re-renders views
5:23
Mike Mikina
Рет қаралды 1 М.
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 390 М.
Правильный MVC
26:14
CocoaHeads
Рет қаралды 5 М.
SwiftUI GeometryReader
27:53
Stewart Lynch
Рет қаралды 10 М.
SwiftUI 5: What’s New In ScrollView
13:07
Mike Mikina
Рет қаралды 8 М.
No Code App Development is a Trap
9:31
Coding with Dee
Рет қаралды 178 М.
What are you going to do in 2023? Tops 5 skills to get!
18:56
David Bombal
Рет қаралды 2,4 МЛН
SwiftUI List with Custom Cell & Passing Data
36:27
Sean Allen
Рет қаралды 115 М.
Hidden FREE Mac Apps!
28:14
Snazzy Labs
Рет қаралды 171 М.
Create a Custom Dialog in SwiftUI
16:52
Mike Mikina
Рет қаралды 7 М.
ВАЖНО! Не проверяйте на своем iPhone после установки на экран!
0:19
ГЛАЗУРЬ СТЕКЛО для iPhone и аксессуары OTU
Рет қаралды 6 МЛН
Здесь упор в процессор
18:02
Рома, Просто Рома
Рет қаралды 429 М.
Это Xiaomi Su7 Max 🤯 #xiaomi #su7max
1:01
Tynalieff Shorts
Рет қаралды 2 МЛН
Что делать если в телефон попала вода?
0:17
Лена Тропоцел
Рет қаралды 3 МЛН
İĞNE İLE TELEFON TEMİZLEMEK!🤯
0:17
Safak Novruz
Рет қаралды 346 М.