iOS
[Swift] Closures (2)
Closures 2편이다. 1편을 보지 않았다면 꼭 보고 오는 걸 추천한다. [Swift] Closures (1) Swift에는 클로저(Closures)라는 개념이 있다. 하나의 코드 블럭이라고 생각하면 이해가 쉽다. { (parameters) -> return type in statements } 클로저는 일반적으로 위와 같은 형태를 가지고 있다. 클로저는 저장 littlemoom.tistory.com 캡처값(Capturing Values) func makeIncrementer(forIncrement amount: Int) -> () -> Int { var runningTotal = 0 func incrementer() -> Int { runningTotal += amount return running..
[Swift] Closures (1)
Swift에는 클로저(Closures)라는 개념이 있다. 하나의 코드 블럭이라고 생각하면 이해가 쉽다. { (parameters) -> return type in statements } 클로저는 일반적으로 위와 같은 형태를 가지고 있다. 클로저는 저장도 가능하다 let sumClosures: (Int, Int) -> Int = { x, y in return x + y } let sumResult = sumClosures(4,5) // 9 클로저 표현식은 축약이 n단계로 가능하다. 공식 문서에서는 sorted(by:) Method가 받는 클로저를 예시로 들었다. func backward(_ s1: String, _ s2: String) -> Bool { return s1 > s2 } let names = ..
![[SwiftUI] Shapes](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fch35JI%2FbtrAhdSciAC%2FUvVpUUozZdRJKspA5OCysK%2Fimg.png)
[SwiftUI] Shapes
Shapes가 UIKit에도 비슷한 개념이 있었는지 모르겠다. 요즘 SwiftUI 코드만 보다보니 UIKit 코드가 점점 잊혀지는거 같은데.... 잊기전에 다시 한 번 봐야겠다. Shapes Rectangle, RoundedRectangle, Circle, Ellipse, Capsule 이 기본 Shape이고, ScaledShape, RotatedShape, OffsetShape, TransformedShape은 기본 Shape을 변형시켜 사용하는 것이다. Rectangle() .fill(.red) .frame(width: 300, height: 40) RoundedRectangle(cornerRadius: 15, style: .circular) .fill(.orange) .frame(width: 290..
![[SwiftUI] User Interface Elements](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbD7Rk3%2FbtrAeO6nNqd%2F9OoqXC51LUuwm9X8t9RHK0%2Fimg.gif)
[SwiftUI] User Interface Elements
제목은 거창하지만 줄이면 그냥 UI 요소들이다 오늘 살펴볼 UI Elements는 Text, Label, TextField, SecureField, TextEditor, Button, EditButton, Link, Menu, Slider, Stepper, Toggle, Picker, DatePicker, ColorPicker, ProgressView 이다. Text, Label, TextField, SecureField, TextEditor Text("Text Input and Output") .font(.title) Text("I'm Text") .textSelection(.enabled) Label("I'm Label", systemImage: "tray.fill") TextField("PlaceH..
![[SwiftUI] View Containers](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbjiP9d%2FbtrAdZGnlhU%2FD7nKwA5XDkn0Ca31smCu3K%2Fimg.gif)
[SwiftUI] View Containers
오늘 SwiftUI의 UI 요소들을 알아보자. 오늘의 문서 https://developer.apple.com/documentation/swiftui View Containers에는 HStack, VStack, ZStack, LazyHStack, LazyVStack, LazyHGrid, LazyVGrid, GridItem, List, ForEach, ScrollView, Form, Group, GroupBox, Section, Spacer, Divider, NavigationView, TabView, Alert, ActionSheet, EmptyView, AnyView, TupleView 등 굉장히 다양한 요소들이 존재한다. 이걸 전부 하나의 View에 담아보려고 했는데, TabView와 Navigatio..