Starbucks Caramel Frappuccino
본문 바로가기
  • 그래 그렇게 조금씩

분류 전체보기273

9. [SwiftUI] .padding() 패딩 고정적인 프레임을 정하는 방법 외에, 패딩을 활용하는 방법도 있다. (고정 된 프레임과 다르게, 텍스트가 길어지면 패딩은 다이나믹하게 적용됨.) 패딩에 패딩에 패딩 // Created by Toughie on 2023/04/04. // import SwiftUI struct padding_spacer: View { var body: some View { VStack(alignment: .leading) { Text("Hello, Toughie!") .font(.largeTitle) .fontWeight(.semibold) .padding(.bottom,20) Text("Hi, SwiftUI! I love coding.Hi, SwiftUI! I love coding.Hi, SwiftUI! I love co.. 2023. 4. 4.
18 - Changing Constraints 제약 변경 https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/ModifyingConstraints.html Auto Layout Guide: Changing Constraints developer.apple.com 제약을 변경하는 방법은? (키보드가 올라올 때 뷰를 위로 쓱 올려서 가려지지 않게 하는 등..) - 제약 활성화 / 비활성화 - 제약의 상수 변경 - 제약의 우선도 변경 - 뷰 계층에서 제약 삭제 제약을 변경하면 레이아웃 엔진이 뷰프레임에 바로 업데이트 하는 것이 아니라 잠깐 뒤에 업데이트 한다. (너무 순식간이라 사실 사람 눈에는.. 안보인다. 뷰 업데이트 주기가 1/60초, 1/.. 2023. 4. 4.
고차함수 ( Higher-order Function)_ map, filter, reduce 스위프트에서 함수는 일급시민(일급객체_First Class Citizen)이기 때문에 함수의 파라미터로 전달 될 수 있고, 함수의 결과값으로 return 할 수도 있다. 고차함수는 함수를 파라미터로 쓰거나, 함수의 결과로 함수를 리턴하는 함수이다. (input과 output이 다 함수일 수 있음_함수는 일급시민이니까) 대표적인 고차함수에는(다른 언어에도 대부분 정의 되어 있음) map, filter, reduce, forEach, compactMap, flatMap이 있는데 먼저 기본인 map, filter, reduce에 대해 알아보고자 한다. 배열, 딕셔너리, 셋과 같은 컬렉션 타입에서 많이 쓰고 대부분 배열에서 자주 쓰는 경우가 많았다. map 시간복잡도 O(n) Returns an array co.. 2023. 4. 4.
0단계🐥 - 짝수의 합 고차함수를 활용할 수 있다. import Foundation func solution(_ n:Int) -> Int { (1...n).filter { $0 % 2 == 0}.reduce(0, +) // (1...n).filter { $0 % 2 == 0}.reduce(0) { $0 + $1 } } n이 정수이기 때문에 1부터 n까지 .filter를 활용해 짝수 배열을 만든다. (filter는 배열을 return하니) 해당 짝수배열에서 .reduce를 통해 합을 구한다. 주석 처리된 부분의 형태를 많이 접했었는데 .reduce(0, +)와 같이 연산자를 활용할 수도 있다. 2023. 4. 4.
17 - Self-Sizing Table View Cells _ 2 self - sizing self-sizing refers to the ability of a view to determine its own size based on its content and constraints. Self-sizing views are a fundamental aspect of building dynamic user interfaces that adapt to different screen sizes and orientations. customCell 파일을 만들어서 스토리보드에서 연결시켜준다. UITableVieCell 변수 이미지뷰 변수 타이틀레이블 변수 디테일레이블 override func awakeFromNib() { super.awakeFromNib() //여기서 cell .. 2023. 4. 4.
16 - Self-Sizing Table View Cells https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithSelf-SizingTableViewCells.html Auto Layout Guide: Working with Self-Sizing Table View Cells developer.apple.com 기존에는 tableView.estimatedRowHeight = 100.0 tableView.rowHeight = UITableViewAutomaticDimension등을 작성해야 했지만, 지금은 하지 않아도 크게 상관 없어졌다. 간단한 테이블뷰와 셀을 만들고 뷰레이어를 살펴보자. UIWindowScene - (For.. 2023. 4. 3.