Skip to content

Commit

Permalink
feat: add new fill equal frame extension and wrapping view in a hoste…
Browse files Browse the repository at this point in the history
…d controller
  • Loading branch information
gtokman committed May 3, 2021
1 parent 5e11862 commit c462a8a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sources/ExtensionKit/SwiftUI/View.swift
Expand Up @@ -3,6 +3,20 @@ import Combine

@available(iOS 13.0, macOS 10.15, *)
public extension View {

/// Self wrapped in an `UIHostingController`
var hosted: UIHostingController<Self> {
return UIHostingController(rootView: self)
}

/// Fill frame height and width to the same length
/// - Parameters:
/// - length: Length to set
/// - alignment: Aligment
/// - Returns: View
func fillEqual(length: CGFloat, alignment: Alignment = .center) -> some View {
self.frame(width: length, height: length, alignment: alignment)
}

/// Fill parent view
/// - Parameter alignment: alignment
Expand Down

0 comments on commit c462a8a

Please sign in to comment.