Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounding rects #3

Closed
artemnovichkov opened this issue May 6, 2019 · 0 comments
Closed

Bounding rects #3

artemnovichkov opened this issue May 6, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@artemnovichkov
Copy link
Contributor

Add bounding rect calculation to Text object like:

    ///Returns the bounding rectangle required to draw the string.
    ///
    /// - Parameters:
    ///   - size: The width and height constraints to apply when computing the string’s bounding rectangle.
    ///   - options: Additional drawing options to apply to the string during rendering.
    ///   - context: A context object with information about how to adjust the font tracking and scaling information.
    /// On return, the specified object contains information about the actual values used to render the string.
    /// This parameter is nil by default.
    ///   - state: The control state for attributes.
    /// - Returns: A rectangle whose size component indicates the width and height required to draw the entire contents of the string.
    public func boundingRect(with size: CGSize,
                             options: NSStringDrawingOptions = [.usesLineFragmentOrigin, .usesFontLeading],
                             context: NSStringDrawingContext? = nil,
                             for state: ControlState = .normal) -> CGRect {
        guard let attributedString = attributed(for: state) else {
            return .zero
        }
        return attributedString.boundingRect(with: size, options: options, context: context)
    }
@artemnovichkov artemnovichkov added the enhancement New feature or request label May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant