Swift & SwiftUI
  • İçerikler
  • UI Bileşenleri
    • Text
    • Button
    • Image
    • Picker
    • SecureField
    • Stepper
    • Slider
    • TabView
    • Sheet
    • Action Sheet
    • Alert
  • Layout
    • Fill-Space-Equally
  • State & Data Flow
    • Content
    • EnvironmentObject
    • ObservableObject
    • ObservedObject
    • Binding
  • Gestures
    • TapGesture
    • DragGesture
    • MagnificationGesture
    • RotationGesture
    • LongPressGesture
    • Notes
  • Extra
    • GeometryReader
    • Timer
    • AlignmentGuide
    • PreferenceKey
  • Concurrency
    • Perform asynchronous operation
Powered by GitBook
On this page

Was this helpful?

  1. Layout

Fill-Space-Equally

PreviousAlertNextContent

Last updated 4 years ago

Was this helpful?

Bir konteynır içindeki kardeşler arasında eşit şekilde bir alanı paylaşmak için frame(maxWidth: CGFloat) ve frame(maxHeight: CGFloat) modifier'ını kullanabiliriz.

  • Yatayda eşit şekilde paylaşmak için;

HStack {
    Button("First Button") {}
        .frame(maxWidth: .infinity)
    Rectangle().foregroundColor(.blue)
        .frame(maxWidth: .infinity)
}.frame(height: 100)

2. elemente aslında ihtiyacınız yok ise Spacer() da kullanabilirsiniz.

  • Dikeyde eşit şekilde paylaştırmak için;

VStack {
    Button("First Button") {}
        .frame(maxHeight: .infinity)
        .background(Color.pink)
    Button("Second Button") {}
        .frame(maxHeight: .infinity)
        .background(Color.orange)
}
.border(Color.green, width: 2)
.frame(height: 100)

frame methodunun maxWidth veya maxHeight parametrelerini kullanarak bir konteynır içindeki View'leri yatay yahut dikey olarak eşit alan paylaşacak şekilde konumlandırabiliriz.

equal spacing horizontally