> For the complete documentation index, see [llms.txt](https://eneskaraosman53.gitbook.io/swiftui/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eneskaraosman53.gitbook.io/swiftui/ui-components/tabview.md).

# TabView

```swift
// Tab geçişlerinin gerçekleştiğini gözlemlemek için
// bir dummy view oluşturalım.
struct SampleTabView: View {
    
    let title: String
    
    var body: some View {
        Text(title)
    }
    
}

struct TabContainerView: View {
    var body: some View {
        TabView {
        
            SampleTabView(title: "Tab - 1")
                .tabItem {
                    Image(systemName: "1.circle.fill")
                    Text("Tab-1").bold()
                }
            
            SampleTabView(title: "Tab - 2")
                .tabItem {
                    Image(systemName: "2.circle.fill")
                    Text("Tab-2").bold()
                }
            
            SampleTabView(title: "Tab - 3")
                .tabItem {
                    Image(systemName: "3.circle.fill")
                    Text("Tab-3").bold()
                }
        }
    }
}
```

![](/files/-M5vLabAo76eBh65d4wO)

**tabItem** düzenleyicisini kullandığımızda `Image` ve `Text` bileşenlerini bizim için otomatik olarak yerleştirir.

#### Ekstra

Sekmeler (Tab (View)) arasında **@EnvironmentObject** kullanarak veri paylaşımı yapabiliriz.

```swift
// Demo için bir dummy class oluşturalım.
class User: Identifiable, Codable {
    var id = UUID()
    var name = ""
}

// EnvironmentObject
class UserService: ObservableObject {
    @Published var users: [User]

    init () {
        self.users = []
    }
}

struct TabContainerView: View {
    var userService = UserService()
    
    var body some: View {
        SampleTabView { .. }
            .environmentObject(userService)
            // Paylaşmak istediğimiz veriyi
            // Bu senaryoda UserService, bu şekilde environmentObject'e
            // argüman olarak geçiyoruz.
    }
}

// Tab View
struct SampleTabView: View {
    @EnvironmentObject var userService: UserService
    // Tab View içinde de bu şekilde, referans olarak geçtiğimiz
    // UserService'e tekrar erişebiliriz.
    
    var body: some View { .. }
}
```

`@EnvironmentObject` kullandığımız zaman SwiftUI, `View` oluşturulduğunda bu o objenin de hazır olduğuna emin oluyor


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://eneskaraosman53.gitbook.io/swiftui/ui-components/tabview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
