[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6825":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":15,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":22,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":16,"starSnapshotCount":16,"syncStatus":32,"lastSyncTime":33,"discoverSource":34},6825,"SwiftUI","Jinxiansen\u002FSwiftUI","Jinxiansen","`SwiftUI` Framework  Learning and Usage Guide. 🚀 ","https:\u002F\u002Fjinxiansen.github.io\u002FSwiftUI\u002F",null,"Swift",5437,532,124,1,0,3,64.98,"MIT License",false,"master",true,[24,25,26,27,28],"articles","swiftui","swiftui-example","wwdc","wwdc2019","2026-06-12 04:00:30","\u003Cimg src=\"images\u002Ficon\u002Fbanner.png\"\u002F>\n\n[![Build Status](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fplatforms-iOS%20%7C%20tvOS%20%7C%20macOS%20%7C%20watchOS-green.svg)](https:\u002F\u002Fgithub.com\u002FJinxiansen\u002FSwiftUI)\n[![Swift](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift-5.1-orange.svg)](https:\u002F\u002Fswift.org)\n[![Xcode](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FXcode-11.0-blue.svg)](https:\u002F\u002Fdeveloper.apple.com\u002Fxcode)\n[![Xcode](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FmacOS-15.0-blue.svg)](https:\u002F\u002Fdeveloper.apple.com\u002FmacOS)\n[![MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicenses-MIT-red.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n\n\nThis article refers to SwiftUI [apple example](https:\u002F\u002Fgithub.com\u002FJinxiansen\u002FSwiftUI\u002Ftree\u002Fdoc) and records the results of the exploration here, I hope to be helpful to you.\n\nFor the content described in this article, by default you have some experience based on Swift language development, so it will not describe every detail in detail; if you have doubts about Swift syntax, you can learn [Swift](https:\u002F\u002Fswift.org) Grammar.\n\nWhen learning and using `SwiftUI`, if you have any questions, you can join the SwiftUI QQ Group: **18552966** to discuss communication.\n\n[中文版🇨🇳](README_CN.md)\n\n> Recommended Preview: [Windows 11](https:\u002F\u002Fgithub.com\u002FJinxiansen\u002FWindows11) desktop client implemented using **SwiftUI**.\n> \n> \u003Cimg width=\"80%\" src=\"images\u002Fwindows11\u002Flaunchpad.png\"\u002F>\n\n\n### ⭐️ Stargazers over time\n\n[![Stargazers over time](https:\u002F\u002Fstarchart.cc\u002FJinxiansen\u002FSwiftUI.svg)](https:\u002F\u002Fstarchart.cc\u002FJinxiansen\u002FSwiftUI)\n\n### 💻 Requirements\n\n- macOS 10.15\n- Xcode 11.0\n- iOS 13.0\n\n\n## Directory：\n\n### Basic View\n\n* \u003Cspan id=\"Text_D\">Text\u003C\u002Fspan>\n\t- [Text](#Text)\n\t- [TextField](#TextField)\n\t- [SecureField](#SecureField)\n\n* \u003Cspan id=\"Image_D\">Image\u003C\u002Fspan>\n\t- [Image](#Image)\n\t- [WebImage](#WebImage)\n\n* \u003Cspan id=\"Button_D\">Button\u003C\u002Fspan>\n\t- [Button](#Button)\n\t- [PullDownButton](#PullDownButton)\n\t- [ItemBasedPopUpButton](#ItemBasedPopUpButton)\n\t- [NavigationButton](#NavigationButton)\n\t- [PresentationButton](#PresentationButton)\n\t- [EditButton](#EditButton)\n\t- [PasteButton](#PasteButton)\n\n* \u003Cspan id=\"Picker_D\">Picker\u003C\u002Fspan>\n\t- [Picker](#Picker)\n\t- [DatePicker](#DatePicker)\n\t- [Toggle](#Toggle)\n\t- [Slider](#Slider)\n\t- [Stepper](#Stepper)\n\t- [SegmentedControl](#SegmentedControl)\n\n* \u003Cspan id=\"Special_D\">Special Views\u003C\u002Fspan>\n\t- [WebView](#WebView)\n\t- [UIViewController](#UIViewController)\n\n### \u003Cspan id=\"Layout_D\">Layout\u003C\u002Fspan>\n\t\n* \u003Cspan id=\"Stacks_D\">Stacks\u003C\u002Fspan>\n\t- [HStack](#HStack)\n\t- [VStack](#VStack)\n\t- [ZStack](#ZStack)\n\n* \u003Cspan id=\"List_D\">List\u003C\u002Fspan>\n\t- [List](#List)\n\t- [ScrollView](#ScrollView)\n\t- [ForEach](#ForEach)\n\n* \u003Cspan id=\"Container_D\">Container Views\u003C\u002Fspan>\n\t- [Group](#Group)\n\t- [GroupBox](#GroupBox)\n\t- [Section](#Section)\n  - [Form](#Form)\n\n* \u003Cspan id=\"Architectural_D\">Architectural Views\u003C\u002Fspan>\n\t- [NavigationView](#NavigationView)\n\t- [TabView](#TabView)\n\t- [HSplitView](#HSplitView)\n\t- [VSplitView](#VSplitView)\n\n* \u003Cspan id=\"Alert_D\"> Alert \u003C\u002Fspan>\n\t- [Alert](#Alert)\n\t- [Modal](#Modal)\n\t- [Popover](#Popover)\n\t- [Sheet](#Sheet)\n\t- [ActionSheet](#ActionSheet)\n\n\n### \u003Cspan id=\"State_D\">State and Data Flow\u003C\u002Fspan>\n\n* \u003Cspan id=\"Bindings_D\"> Bindings \u003C\u002Fspan>\n\t* [Binding](#Binding)\n\n* \u003Cspan id=\"Data_D\"> Data-Dependent Views \u003C\u002Fspan>\n\t* [State](#State)\n\t* [ObjectBinding](#ObjectBinding)\n\t* [EnvironmentObject](#EnvironmentObject)\n\n* \u003Cspan id=\"Environment_D\"> Environment Values \u003C\u002Fspan>\n\t* [Environment](#Environment)\n\t* [EnvironmentValues](#EnvironmentValues)\n\n* \u003Cspan id=\"ENavigation_D\"> ENavigation Models \u003C\u002Fspan>\n\t* [DynamicNavigationDestinationLink](#DynamicNavigationDestinationLink)\n\n* \u003Cspan id=\"Preferences_D\"> Preferences \u003C\u002Fspan>\n\t* [LocalizedStringKey](#LocalizedStringKey)\n\n* \u003Cspan id=\"Transactions_D\"> Transactions \u003C\u002Fspan>\n\t* [Transaction](#Transaction)\n\n\n### \u003Cspan id=\"Gestures_D\">Gestures\u003C\u002Fspan>\n\n* \u003Cspan id=\"BasicGestures_D\"> Basic Gestures \u003C\u002Fspan>\n\t* [TapGesture](#TapGesture)\n\t* [LongPressGesture](#LongPressGesture)\n\t* [DragGesture](#DragGesture)\n\t* [MagnificationGesture](#MagnificationGesture)\n\t* [RotationGesture](#RotationGesture)\n\n* \u003Cspan id=\"Combined_D\"> Combined Gestures \u003C\u002Fspan>\n\t* [SequenceGesture](#SequenceGesture)\n\t* [SimultaneousGesture](#SimultaneousGesture)\n\t* [ExclusiveGesture](#ExclusiveGesture)\n\n* \u003Cspan id=\"Custom_D\"> Custom Gestures \u003C\u002Fspan>\n\t* [AnyGesture](#AnyGesture)\n\n\n\u003Ch2 id=\"Basic View\">Basic View\u003C\u002Fh2>\n\n\n\u003Ch4 id=\"Text\">Text\u003C\u002Fh4>\n\n`Text` is used to display one or more lines of text content with the same effect as `UILabel`, but it is even better.\n\nIf you want to create `Text`, just create it with `Text(\"SwiftUI\")`;\nWith chained syntax, you can also add multiple attributes to the text, such as fonts, colors, shadows, spacing between top left and right, and so on.\n\nExample:\n\n```swift\n\nText(\"SwiftUI\")\n    .foregroundColor(.orange)\n    .bold()\n    .font(.system(.largeTitle))\n    .fontWeight(.medium)\n    .italic()\n    .shadow(color: .black, radius: 1, x: 0, y: 2)\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n  \u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FText.png\"\u002F>\n\u003C\u002Fdetails>\n\n \n> HStack and VStack controls are used to host multiple views, as mentioned later.\n\n[🔝](#Text_D)\n\n\u003Ch4 id=\"TextField\"> TextField \u003C\u002Fh4>\n \n`TextField` is used to add a normal input box, which is often used as a text input.\n\nExample：\n\n```swift\n\nTextField(self.$name, placeholder: self.nameText, onEditingChanged: { changed in\n    print(\"onEditing: \\(changed)\")\n}) {\n    print(\"userName: \\(self.name)\")\n    self.endEditing(true)\n}}\n.padding(10)\n.frame(height: 50)\n.textFieldStyle(RoundedBorderTextFieldStyle())\n.padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20))\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FField.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Text_D)\n\n\u003Ch4 id=\"SecureField\"> SecureField \u003C\u002Fh4>\n\n`SecureField ` is generally used as a password input. It is used in the same way as `TextField`. The example and the running effect are the same as `TextField`.\n\n\n\u003Ch4 id=\"Image\"> Image \u003C\u002Fh4>\n\nThe `Image` control is used to display images, example:\n\n```swift\n\nImage(\"icon\")\n    .resizable()\n    .frame(width: 100,\n           height: 100,\n           alignment: .center)\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FImage.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Text_D)\n\n\u003Ch4 id=\"WebImage\"> WebImage \u003C\u002Fh4>\n\n`webImage` is used to download the web image, use the `URLSession` to download the original `Image` after successful download; you can also use [Kingfisher]((https:\u002F\u002Fgithub.com\u002Fonevcat\u002FKingfisher)) in the `downloadWebImage ` function .\n\nExample：\n\n```swift\n\nvar body: some View {\n        Image(uiImage: self.uiImage ?? placeholderImage)\n            .resizable()\n            .onAppear(perform: downloadWebImage)\n            .frame(width: 80,\n                   height: 80,\n                   alignment: .center)\n            .onTapGesture {\n                print(\"Tap \")\n        }\n    }\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FWebImage.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Text_D)\n\n\u003Ch4 id=\"Button\"> Button \u003C\u002Fh4>\n\n`Button` is used to respond to click events.\n\nExample:\n\n```swift\n\nButton(action: {\n    print(\"Tap\")\n}) {\n   Text(\"I'm a Button\")\n}\n\n```\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FButton.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Button_D)\n\n\u003Ch4 id=\"PullDownButton\"> PullDownButton \u003C\u002Fh4>\n\nWaiting for release.\n\n\u003Ch4 id=\"ItemBasedPopUpButton\"> ItemBasedPopUpButton \u003C\u002Fh4>\n\nWaiting for release.\n\n\n\u003Ch4 id=\"NavigationButton\"> NavigationButton \u003C\u002Fh4>\n\n`NavigationButtonPage ` is used to push to the next navigation page.\n\nExample:\n\n```swift\n\nNavigationLink(destination: NavigationButtonPage()) {\n            Text(\"NavigationButton\").bold()\n                .foregroundColor(.orange)\n                .font(.largeTitle)\n            }\n    .navigationBarTitle(Text(\"Page\"))\n\n```     \n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FNavigationButton.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Button_D)\n\n\u003Ch4 id=\"PresentationButton\" style='color:red'> PresentationButton is deprecated\u003C\u002Fh4>\n\n`PresentationButton` ~~is used to pop up a page.~~ has deprecated, please use `NavigationLink` \n\n\n[🔝](#Button_D)\n\n\u003Ch4 id=\"EditButton\"> EditButton \u003C\u002Fh4>\n\n`EditButton` is used to trigger the editing state, just use the `navigationBarItems` setting when using it. \n\nExample:\n\n```swift\n\nnavigationBarItems(trailing: EditButton())\n\n```     \n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FEditButton.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Button_D)\n\n\u003Ch4 id=\"PasteButton\"> PasteButton \u003C\u002Fh4> \n\nWaiting for release.\n \n\n\u003Ch4 id=\"Picker\"> Picker \u003C\u002Fh4>\n\n`Picker` can customize the selector of the data source.\n\nExample:\n\n```swift\n\nPicker(selection: $leftIndex, label: Text(\"Picker\")) {\n    ForEach(0..\u003CleftSource.count) {\n        Text(self.leftSource[$0]).tag($0)\n    }\n    }.frame(width: UIScreen.main.bounds.width\u002F2)\n\n```     \n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FPicker.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Picker_D)\n\n\u003Ch4 id=\"DatePicker\"> DatePicker \u003C\u002Fh4>\n\n`DatePicker` is used to select the absolute date of the control.\n\nExample:\n\n```swift\n\nDatePicker(selection: $server.date, \nin: server.spaceDate, \ndisplayedComponents: .date, label: {\n    Text(\"\")\n})\n\n```     \n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FDatePicker.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Picker_D)\n\n\u003Ch4 id=\"Toggle\"> Toggle \u003C\u002Fh4>\n\n`Toggle` is used to switch the selected state, for example:\n\n```swift\n\nToggle(isOn: $isOn) {\n    Text(\"State: \\(self.isOn == true ? \"Open\":\"open\")\")\n}.padding(20)\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FToggle.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Picker_D)\n\n\u003Ch4 id=\"Slider\"> Slider \u003C\u002Fh4>\n\n`Slider ` A control for selecting values from a finite range of values, example:\n\n```swift\n\nSlider(value: $data.rating)\n\n```     \n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FSlider.png\"\u002F>\n\u003C\u002Fdetails>\n \n [🔝](#Picker_D)\n\n\u003Ch4 id=\"Stepper\"> Stepper \u003C\u002Fh4>\n\n`Stepper ` is used to increase or decrease the value, example:\n\n```swift\n\nStepper(value: $value, step: 2, onEditingChanged: { c in\n    print(c)\n}) {\n    Text(\"Stepper Value: \\(self.value)\")\n    }.padding(50)\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FStepper.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Picker_D)\n\n\u003Ch4 id=\"SegmentedControl\" style=\"color:red\">SegmentedControl is deprecated\u003C\u002Fh4>\n\n`SegmentedControl ` is used for segmentation condition selection, example:\n\n```swift\n\nSegmentedControl(selection: $currentIndex) {\n    ForEach(0..\u003Citems.count) { index in\n        Text(self.items[index]).tag(index)\n    }\n    }.tapAction {\n        print(\"currentIndex: \\(self.currentIndex)\")\n}\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FSegmentedControl.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Picker_D)\n\n\u003Ch4 id=\"WebView\"> WebView \u003C\u002Fh4>\n\n`WebView` is used to display an open web page, example:\n\n```swift\n\nstruct WebViewPage : UIViewRepresentable {\n    func makeUIView(context: Context) -> WKWebView  {\n        return WKWebView()\n    }\n    func updateUIView(_ uiView: WKWebView, context: Context) {\n        let req = URLRequest(url: URL(string: \"https:\u002F\u002Fwww.apple.com\")!)\n        uiView.load(req)\n    }\n}\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FWebView.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Special_D)\n\n\u003Ch4 id=\"UIViewController\"> UIViewController \u003C\u002Fh4>\n\n`UIViewController` is used to display the **UIViewController** that opens **UIKit** in **SwiftUI** and opens the `SwiftUI` View in **UIViewController**.\n\nExample:\n\nFirst define:\n\n```swift\n\nstruct ControllerPage\u003CT: UIViewController> : UIViewControllerRepresentable {\n    \n    typealias UIViewControllerType = UIViewController\n    \n    func makeUIViewController(context: UIViewControllerRepresentableContext\u003CControllerPage>) -> UIViewController {\n        return T()\n    }\n    \n    func updateUIViewController(_ uiViewController: UIViewController, context: UIViewControllerRepresentableContext\u003CControllerPage>) {\n        debugPrint(\"\\(#function)：\\(type(of: T.self))\")\n    }\n    \n}\n\n```\n\nThen use this:\n\n```swift\n\nNavigationButton(destination: ControllerPage\u003CUIKitController>()) {\n    PageRow(title: \"UIViewController\",subTitle: \"Open UIViewController\")\n\n}\n\n```\n\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FUIViewController.png\"\u002F>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FUIViewController2.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Special_D)\n\n\n### Layout \n\n\n\u003Ch4 id=\"HStack\"> HStack \u003C\u002Fh4>\n\n`HStack` is used to arrange the subviews on a horizontal line. \n\nExample:\n\n```swift\n\nHStack {\n    Text(\"made in China.\")\n    Divider() \u002F\u002F Just add a line.\n    Text(\"the People's Republic Of China.\")\n}\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FHStack.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n\n\u003Ch4 id=\"VStack\"> VStack \u003C\u002Fh4>\n\n`VStack` is used to arrange the subviews on a vertical line.\n\nExample:\n\n```swift\n\nVStack {\n    Text(\"made in China.\")\n    Divider() \u002F\u002F Just add a line.\n    Text(\"the People's Republic Of China.\")\n}\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FVStack.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n\n\u003Ch4 id=\"ZStack\"> ZStack \u003C\u002Fh4>\n\n`ZStack` is used to override the subview, aligned on two axes.\n\nExample:\n\n```swift\n\nZStack {\n    Text(\"made in China.\")\n    Divider() \u002F\u002F Just add a line.\n    Text(\"the People's Republic Of China.\")\n}\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FZStack.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n\n\u003Ch4 id=\"List\"> List \u003C\u002Fh4>\n\n`List` list container to display a list of data.\n\nExamples:\n\n```swift\n\nList(0..\u003C5) { item in\n    Text(\"Hello World !\")\n}.navigationBarTitle(Text(\"List\"), displayMode: .large)\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FList.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n\n\u003Ch4 id=\"ScrollView\"> ScrollView \u003C\u002Fh4>\n\n`ScrollView` is a scroll view container.\n\nExample:\n\n```swift\n\nScrollView {\n    Text(\"SwiftUI\").padding(20)\n    Divider()\n    Image(\"icon\").resizable()\n        .frame(width: 300, height: 300, alignment: .center)\n    Divider()\n    Text(\"Views and ... user interface.\")\n    }\n    .border(Color.gray.gradient, width: 1)\n            .cornerRadius(10)\n            .padding(10)\n            .navigationBarTitle(Text(\"ScrollView\"))\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FScrollView.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n\n\u003Ch4 id=\"ForEach\"> ForEach \u003C\u002Fh4>\n\n`ForEach` is used to present a view based on a collection of existing data.\n\nExample:\n\n```swift\n\nlet data = (0..\u003C5)\nvar body: some View {\n    ForEach(data) { e in\n        Text(\"Hello \\(e)\")\n            .bold()\n            .font(.system(size: 25, design: .monospaced))\n            .padding(5)\n}\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FForEach.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n\n\u003Ch4 id=\"Group\"> Group \u003C\u002Fh4>\n\n`Group` is used to aggregate multiple views, and the properties set on the Group will be applied to each child view.\n\nExample:\n\n```swift\n\nGroup {\n        Text(\"Hello World !\")\n        Text(\"Hello World !\")\n      }\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FGroup.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n \n\u003Ch4 id=\"GroupBox\"> GroupBox \u003C\u002Fh4>\n\nWaiting for release.\n\n\n\u003Ch4 id=\"Section\"> Section \u003C\u002Fh4>\n\n`Section` is used to create the **header\u002Ffooter** view content, which is generally used in conjunction with the `List` component.\n\nExample:\n\n```swift\n\nSection(header: Text(\"I'm header\"), footer: Text(\"I'm footer\")) {\n    ForEach(0..\u003C3) {\n        Text(\"Hello \\($0)\")\n    }\n}\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FSection.png\"\u002F>\n\u003C\u002Fdetails>\n\n\u003Ch4 id=\"Form\"> Form \u003C\u002Fh4>\n\n`Form` A container for grouping controls used for data entry, such as in settings or inspectors.\n\nExample:\n\n```swift\n\nForm {\n   TextField(\"First Name\", text: $firstName)\n   TextField(\"Last Name\", text: $lastName)\n}\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FForm.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n \n\u003Ch4 id=\"NavigationView\"> NavigationView \u003C\u002Fh4>\n\n`NavigationView` is used to create a view container that contains the top navigation bar.\n\nExample:\n\n```swift\n\nNavigationView {\n            Text(\"🧚‍♂️🧚‍♀️🧜‍♂️🧜‍♀️🧞‍♂️🧞‍♀️\").blur(radius: 5)\n            Text(\"Swifter Swifter\")\n            .bold()\n                .foregroundColor(.orange)\n                .font(.largeTitle)\n        }\n    .navigationBarTitle(Text(\"NavigationView\"))\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FNavigationView.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n\n\u003Ch4 id=\"TabView\"> TabView \u003C\u002Fh4>\n\n`TabView` is used to create a view container that contains the bottom ** TabBar**.\n\nExample:\n\n```swift\n\nTabView(selection: $index) {\n    ForEach(0..\u003Cimgs.count) { item in\n        TabItemPage(index: item)\n            .tabItem{\n                Image(self.imgs[item])\n                Text(\"\\(item)\")\n        }\n        .tag(item)\n    }\n}\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FTabView.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Layout_D)\n\n\u003Ch4 id=\"HSplitView\"> HSplitView \u003C\u002Fh4> \n\nWaiting for release.\n\n\u003Ch4 id=\"VSplitView\"> VSplitView \u003C\u002Fh4> \n\nWaiting for release.\n\n[🔝](#Layout_D)\n\n\u003Ch4 id=\"Alert\"> Alert \u003C\u002Fh4>\n\n`Alert` is used to display a bullet reminder that needs to be associated with a trigger event.\n\nExample:\n\n```swift\n\nalert(isPresented: $showAlert, content: {\n            Alert(title: Text(\"确定要支付这100000000美元吗？\"),\n                  message: Text(\"请谨慎操作\\n一旦确认，钱款将立即转入对方账户\"),\n                  primaryButton: .destructive(Text(\"确认\")) { print(\"转出中...\") },\n                  secondaryButton: .cancel())\n        }).navigationBarTitle(Text(\"Alert\"))\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FAlertPage.jpg\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Alert_D)\n\n\n\u003Ch4 id=\"ActionSheet\"> ActionSheet \u003C\u002Fh4>\n\n`ActionSheet` is used to pop up a selection box.\n\nExample:\n\n```swift\n\nActionSheet(title: Text(\"Title\"),\n            message: Text(\"Message\"),\n            buttons:\n    [.default(Text(\"Default\"), onTrigger: {\n        print(\"Default\")\n        self.showSheet = false\n    }),.destructive(Text(\"destructive\"), onTrigger: {\n        print(\"destructive\")\n        self.showSheet = false\n    }),.cancel({\n        print(\"Cancel\")\n        self.showSheet = false\n    })])\n```\n\nusage：\n\n```swift \n\n.actionSheet(isPresented: $showSheet, content: {sheet})\n\n```\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FActionSheet.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Alert_D)\n\n\n\u003Ch4 id=\"Modal\"> Modal \u003C\u002Fh4>\n\n`Modal` is used to pop up a view.\n\nExample:\n\n```swift\n\nModal(Text(\"Modal View\"),onDismiss: {\n    print(\"View Dismiss !\")\n})\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FModal.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Alert_D)\n\n\n\u003Ch4 id=\"Popover\"> Popover \u003C\u002Fh4>\n\n`Popover` is used to pop up a view, see the results below.\n\nExample:\n\n```swift\n\n.popover(isPresented: $showPop, content: {\n                ImagePage()\n        })\n\n```\n\n\u003Cdetails close>\n  \u003Csummary>View running results\u003C\u002Fsummary>\n\u003Cimg width=\"80%\" src=\"images\u002Fexample\u002FPopover.png\"\u002F>\n\u003C\u002Fdetails>\n\n[🔝](#Alert_D)\n\n## 📎 About\n\n* The code involved in the above example is in this repository code. It is recommended to download and run the view.\n* If you have better usage and suggestions about SwiftUI, look forward to sharing it!\n* If there are omissions and errors in the examples in this article,  please create a [**Issue**](https:\u002F\u002Fgithub.com\u002FJinxiansen\u002FSwiftUI\u002Fissues\u002Fnew) !\n \n\n\n## ✉️ Contacts\n\nemail : hi@jinxiansen.com\n\n微博 : [@晋先森](http:\u002F\u002Fweibo.com\u002F3205872327)\n\n## 📄 License\t\n\nSwiftUI is released under the [MIT license](LICENSE). See LICENSE for details.\n\n","该项目是一个 SwiftUI 框架的学习和使用指南，旨在帮助开发者理解和掌握 SwiftUI 的核心概念与实践技巧。它详细介绍了 SwiftUI 中的各种视图组件（如文本、按钮、选择器等）及其布局方式，并通过实例代码展示了如何在 iOS、tvOS、macOS 和 watchOS 平台上构建用户界面。特别适合于有一定 Swift 开发基础的程序员，在开发跨平台应用时参考学习。此外，项目还提供了丰富的示例和详细的文档说明，便于快速上手并深入理解 SwiftUI 的强大功能。",2,"2026-06-11 03:09:04","top_language"]