0xLet / SwiftUIKit

📱 UIKit code that is fun to write
https://0xlet.github.io/SwiftUIKit/
MIT License
74 stars 6 forks source link

SafeAreaView should allow for selecting the safe area padding #182

Closed 0xLeif closed 3 years ago

0xLeif commented 3 years ago

Is your feature request related to a problem? Please describe. When trying to respect the SafeArea, sometimes we don't want to respect all of it.. maybe we just want to respect the topAnchor.

Describe the solution you'd like

extension SafeAreaView {
    init(padding: [Padding], content: () -> UIView) {
        // ...
    }
}

Describe alternatives you've considered One could embed a view and then manually update the constraints.

Additional context N/A

0xLeif commented 3 years ago
//
//  ViewController.swift
//  ExamSIUIK
//
//  Created by Leif on 3/22/21.
//

import UIKit
import SwiftUIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        view.embed {
            SafeAreaView {
                Image(color: .orange)
            }
            .ignore(
                leadingAnchorWithPadding: 0,
                trailingAnchorWithPadding: 0,
                bottomAnchorWithPadding: 0
            )
        }
    }
}
0xLeif commented 3 years ago

image