let backImage = UIImage(systemName: "arrow.backward") navigationBar.backIndicatorImage = backImage navigationBar.backIndicatorTransitionMaskImage = backImage navigationBar.tintColor = .white UINavigationController를 상속받는 ViewController class 의 viewDidLoad() 안에서 사용하였다.
전체 글
let section = NSCollectionLayoutSection(group: group) section.orthogonalScrollingBehavior = .continuous 현재 섹션의 너비에 구애받지 않고 horizontal scroll하려면 orthogonalScrollingBehavior을 .continous로 해주면 된다. 그러면 좌우로 스크롤이 가능해진다. 속성을 .groupPaging으로 바꿔주면 옆으로 스크롤 할 때 페이지를 넘기는 애니메이션으로 끊어지면서 보여진다.
dataList = dataList.sorted(by: { data0, data1 in return data0.name > data1.name }) dataList.sort { $0.name > $1.name } dataList를 name에 따라 정렬 $0이 더 크게 정렬, 내림차순
//2022-10-3 >> 10/3 func formattingDateString(_ dateString: String) -> String { let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd " if let date = formatter.date(from: dateString) { formatter.dateFormat = "M/d" return formatter.string(from: date) } else { return "" } } https://developer.apple.com/documentation/foundation/dateformatter Apple Developer Documentation developer.apple..
함수 사용 textLabel.textColor = convertDiffColor(dif: money) func convertDiffColor(dif: Double) -> UIColor { guard dif > 0 else { return .systemBlue } return .systemRed } double타입인 money를 인자로 받아 연산하여 textColor을 변환한다. 0보다 크면 systemRed를, 0보다 작으면 .systemBlue로 표시한다. 삼항연산자 사용 diffLabel.textColor = stock.diff > 0 ? .systemRed : .systemBlue // (조건) ? (true일때) : (false일때)
func convertToCurrencyFormat(price: Int) -> String { let numberFormatter = NumberFormatter() numberFormatter.numberStyle = .decimal numberFormatter.maximumFractionDigits = 0 let result = numberFormatter.string(from: NSNumber(value: price)) ?? "" return result }
textView에서는 multi-line을 입력하기 때문에, 다음의 메서드를 추가하여 엔터 입력을 감지할 수 있다. func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { guard text == "\n" else { return true } dismiss(animated: true) return true } 반환 값(Return Value) true >> if the old text should be replaced by the new text 이전 텍스트를 새 텍스트로 대체해야 할 경우 false >> if the replacement operation s..

import UIKit final class SourceTextViewController: UIViewController { private let placeholderText = "텍스트를 입력해주세요" private lazy var textView: UITextView = { let textView = UITextView() textView.text = placeholderText textView.textColor = .secondaryLabel textView.font = .systemFont(ofSize: 16, weight: .semibold) textView.returnKeyType = .done textView.delegate = self return textView }() override f..