Latest 1.0
Homepage https://github.com/igormatyushkin014/Frame
License MIT
Platforms ios 9.0
Authors

Frame








Simplifies work with layout in iOS. Provides set of tools for managing view’s position, size and many other things.

How To Get Started

  • Copy content of Source folder to your project.

or

  • Use Frame cocoapod

Requirements

  • iOS 9 and later
  • Xcode 9 and later
  • Swift 4

Usage

String

Height of string with attributes:

let attributes: [NSAttributedStringKey : Any] = [
    .font: UIFont.systemFont(ofSize: 36.0, weight: .thin),
    .kern: 0.5
]

let height = "Some text".frm.height(forWidth: 200, andAttributes: attributes)

Width of string with attributes:

let width = "Some text".frm.width(forHeight: 200, andAttributes: attributes)

Size that fits:

let constraintSize = CGSize(width: 200, height: CGFloat.greatestFiniteMagnitude)
let sizeThatFits = "Some text".frm.sizeThatFits(constraintSize, withAttributes: attributes)

NSAttributedString

Height of attributed string:

let attributes: [NSAttributedStringKey : Any] = [
    .font: UIFont.systemFont(ofSize: 36.0, weight: .thin),
    .kern: 0.5
]

let attributedString = NSAttributedString(string: "Some text", attributes: attributes)
let height = attributedString.frm.height(forWidth: 200)

Width of attributed string:

let width = attributedString.frm.width(forHeight: 200)

Size that fits:

let constraintSize = CGSize(width: 200, height: CGFloat.greatestFiniteMagnitude)
let sizeThatFits = attributedString.frm.sizeThatFits(constraintSize)

UILabel

Label’s height to fit attributed text:

let attributes: [NSAttributedStringKey : Any] = [
    .font: UIFont.systemFont(ofSize: 36.0, weight: .thin),
    .kern: 0.5
]

let attributedString = NSAttributedString(string: "Some text", attributes: attributes)
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 0))
let height = label.frm.height(forAttributedText: attributedString)

CGRect

Inset:

let sourceFrame = CGRect(x: 20, y: 20, width: 500, height: 350)
let resultFrame = sourceFrame.frm.inset(top: 10, left: 10, bottom: 10, right: 10) // (30, 30, 480, 330)

Offset:

let sourceFrame = CGRect(x: 20, y: 20, width: 500, height: 350)
let resultFrame = sourceFrame.frm.offset(top: 10, left: 10, bottom: 10, right: 10) // (10, 10, 520, 370)

License

Frame is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Frame",
    "version": "1.0",
    "summary": "Set of methods to work with layout in iOS",
    "description": "Simplifies work with layout in iOS. Provides set of tools for managing view's position, size and many other things.",
    "homepage": "https://github.com/igormatyushkin014/Frame",
    "screenshots": "https://github.com/igormatyushkin014/Frame/raw/master/Images/logo_2048_2048.png",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Igor Matyushkin": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/igormatyushkin014/Frame.git",
        "tag": "1.0"
    },
    "source_files": [
        "Source",
        "Source/**/*"
    ],
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This