.frame()

// 2022.02.14 + (method) .frame(cgfloat)

import SwiftUI

// ๐ŸŒ€View+frame()
extension View {
    
    /// Examples:
    /// ```
    /// view.frame(size)
    /// view.frame(nil)
    /// ```
    public func frame(_ size: CGSize?, alignment: Alignment = .center) -> some View {
        frame(width: size?.width, height: size?.height, alignment: alignment)
    }
    
    /// `view.frame(w, h)`
    public func frame(_ width: CGFloat, _ height: CGFloat) -> some View {
        frame(width: width, height: height)
    }
    
    /// `view.frame(cgfloat)`
    public func frame(_ size: CGFloat) -> some View {
        frame(width: size, height: size)
    }
    
}

History

  1. 2020.10.12๏ผšโœ๏ธ .frame(_ size:CGSize) ๆ”น็‚บ CGSize?

  2. 2022.02.07: / ็ฐกๅŒ– .frame(size) ่ชžๆณ•ใ€‚

Last updated