CGRect

public extension CGRect
  • SwifterSwift: Return center of rect

    Declaration

    Swift

    var center: CGPoint { get }

Initializers

  • SwifterSwift: Create a CGRect instance with center and size

    Declaration

    Swift

    init(center: CGPoint, size: CGSize)

    Parameters

    center

    center of the new rect

    size

    size of the new rect

Methods

  • SwifterSwift: Create a new CGRect by resizing with specified anchor

    Declaration

    Swift

    func resizing(to size: CGSize, anchor: CGPoint = CGPoint(x: 0.5, y: 0.5)) -> CGRect

    Parameters

    size

    new size to be applied

    anchor

    specified anchor, a point in normalized coordinates - ‘(0, 0)’ is the top left corner of rect,’(1, 1)‘ is the bottom right corner of rect, defaults to ’(0.5, 0.5)‘. excample:

    anchor = CGPoint(x: 0.0, y: 1.0):

              A2------B2
    

    A—-B | | | | –> | | C—-D C——-D2