본문 바로가기

2022/09/28

(4)
14 ~ 15. TextField & TextField Style & TextEditor TextField Apple Developer Documentation developer.apple.com TextField는 한 줄 입력에 최적화된 View이다. struct LabelView: View { @State private var value = "" var body: some View { Form { Text("testing") .padding() TextField("title", text: $value, prompt: Text("prompt1")) .padding() TextField("title", text: $value) .padding() } } } 생성자의 기본 파라미터는 세 개로 아래와 같다. title iOS와 iPadOS에서 placeholder로 사용된다. macOS에서 La..
13. Label & Font Label Apple Developer Documentation developer.apple.com Label은 이미지와 문자열을 표시하기에 적합한 View다. SwiftUI 초기에는 존재하지 않았기 때문에 하위 호환성을 고려해 사용해야 한다. struct LabelView: View { var body: some View { Label("Bulb", systemImage: "lightbulb") } } 기본 형태는 title + systemImage이고, Custom은 title + iCon으로 이 경우엔 Image View와 Text View를 조합해 사용하는 것과 크게 다르지 않다. struct LabelView: View { var body: some View { NavigationView { B..
사라진 'Info.plist' 파일 다시 만들기 프로젝트를 생성하거나 기존에 생성된 프로젝트를 사용하려는 경우 필요한 'Info.plist' 파일이 보이지 않는 경우가 있다. 문제를 해결해 보자 해결법은 간단하다. Project > Targets > Info 로 접근한 뒤 Key에 'App Transport Security Settings'를 추가하고 하위에 'Allow Arbitrary Loads'를 추가한다. Value는 'YES'로 설정한다. 짠, 간단하게 'Info.plist' 파일이 다시 나타났다.
12. Text Text 문자열을 표시하는 가장 기초적인 View이지만 기능이 꽤나 많은 편에 속한다. Locailzed String Localizable 파일 생성하기 프로젝트 내에 'Strings File'을 생성하고, 이름을 Localizable로 변경한다. 다른 이름을 사용하지 않는 것이 좋다. Localizable 파일 적용하기 프로젝트의 설정에서 Localizations를 찾아 원하는 언어를 추가한다. 이때 우측 상단의 검색을 이용하면 편리하다. Base와 English가 기본으로 적용돼 있다. 앞서 생성한 Localizable.strings 파일을 선택한 뒤 File Inspector에서 'Localize...' 버튼을 누른다. 아무 언어나 선택해 Localize를 누르면 이전에 눌었던 Localize.....