분류 전체보기44 ProgressView struct ProgressContentView: View { var body: some View { VStack(spacing: 30) { ProgressView(value: 37, total: 100) .progressViewStyle(.linear) .padding() ProgressView(value: 28, total: 100) .progressViewStyle(.circular) .padding() } } } Timer를 이용해서 ProgressView 상태를 1초마다 10씩 증가해보았다. 시작, 일시정지, 중지 버튼에 따라 타이머가 동작하도록 하였고 타이머 상태에 따라 버튼의 활성 상태를 변경하였다. struct ProgressContentView: View { private let PROG.. 2023. 11. 21. TextField & SecureField 일반적인 텍스트를 입력받는 경우 TextField를, 비밀번호와 같이 보안이 필요한 텍스트를 입력받는 경우 SecureField를 사용한다. struct TextFieldContentView: View { @State private var userId: String = "" @State private var userPw: String = "" var body: some View { VStack(alignment: .leading) { Text("ID") TextField("ID", text: $userId) .textFieldStyle(.roundedBorder) Spacer().frame(height: 30) Text("Password") SecureField("Password", text: $user.. 2023. 11. 21. Toggle init(isOn: Binding, @ViewBuilder label: () -> Label) struct ToggleContentView: View { @State private var isOn = false var body: some View { Toggle(isOn: $isOn) { Label("WiFi", systemImage: isOn ? "wifi" : "wifi.slash") } .onChange(of: isOn) { oldValue, newValue in print("\(oldValue) -> \(newValue)") // 토글 이벤트 확인. } .font(.title) .frame(width: 180) } } A defualt toggle style is switch. You can ch.. 2023. 11. 20. TabView struct ContentView: View { var body: some View { TabView { ReceivedView() .badge(2) .tabItem { Label("Received", systemImage: "tray.and.arrow.down.fill") } SentView() .tabItem { Label("Sent", systemImage: "tray.and.arrow.up.fill") } AccountView() .tabItem { Image(systemName: "person.crop.circle.fill") Text("Account") } } } } tabItem에 Label 대신 Image와 Text를 따로 넣어도 되며, 순서 상관없이 아이콘이 위, 글자가 아래로 보여지게 .. 2023. 11. 20. 이전 1 ··· 7 8 9 10 11 다음