Code Monkey home page Code Monkey logo

ios.blog.uilabel_typography_extensions's Introduction

UILabel Typography Extensions ๐Ÿ“

Set UILabel line height, letter spacing (and more).

let headerLabel = UILabel()
headerLabel.textColor = UIColor(named: "Mars")
headerLabel.font = UIFont(name: "HelveticaNeue-CondensedBlack", size: 100)
headerLabel.lineHeight = 80
headerLabel.letterSpacing = 100 * -0.02
headerLabel.text = "Mars"

See the complementary article at UILabel line height, letter spacing and more UILabel typography extensions.

How it works

It is an extension on UILabel that adds some typographic properties using Objective-C Runtime (for stored properties on a Swift extension), NSAttributedString (for manage typographic properties), and NSKeyValueObservation (to be able to use the regular text property to manage text content).

It also takes care of baselineOffset values to keep the text content in the vertical center (right). By default, NSAttributedString sticks multiline label content to the top of the container view (left), which makes it hard to match the UI with the design specifications.

Using this extension you can build screens that 100% match design specifications. More on that in the article at UILabel line height, letter spacing and more UILabel typography extensions.

License

Licensed under the MIT License.

ios.blog.uilabel_typography_extensions's People

Contributors

geri-borbas avatar vol24pl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.