All Projects → alexmx → AMXFontAutoScale

alexmx / AMXFontAutoScale

Licence: MIT license
⚠️ Experimental automatic cross-device font scaling for UILabel and UITextView.

Programming Languages

objective c
16641 projects - #2 most used programming language
swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to AMXFontAutoScale

Swiftcocoadsl
An easy way to write iOS UI
Stars: ✭ 103 (+164.1%)
Mutual labels:  uilabel, uitextview
RZColorful
NSAttributedString富文本的方法集合,以及简单优雅的使用其多种属性
Stars: ✭ 53 (+35.9%)
Mutual labels:  uilabel, uitextview
Nudein
An easy-to-use attributed text view for iOS Apps,use like masonry
Stars: ✭ 450 (+1053.85%)
Mutual labels:  uilabel, uitextview
Atributika
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement.
Stars: ✭ 845 (+2066.67%)
Mutual labels:  uilabel, uitextview
Dwanimatedlabel
An UILabel subclass that lets you animate text with different types
Stars: ✭ 252 (+546.15%)
Mutual labels:  uilabel
Skautoscrolllabel
Automatically scrolling UILabel with both horizontal/vertical MARQUEE effects and gradient gradients on the edges. Gradient fading is used on the edge of the scroll to solve the problem of the hard edges of the rolling edge. The overall effect is a natural and easy to use.
Stars: ✭ 64 (+64.1%)
Mutual labels:  uilabel
Nelinelabel
🖋 A UILabel subclass that adds a decorative line / separator
Stars: ✭ 36 (-7.69%)
Mutual labels:  uilabel
Cltypinglabel
iOS UILabel with character by character typing /typewriter animation
Stars: ✭ 192 (+392.31%)
Mutual labels:  uilabel
Sodieremojikeyboardplus
支持自定义emoji表情,icon font , FontAwesome,斜体,超链接,粗体,下划线,字体,颜色,镂空字体等富文本
Stars: ✭ 14 (-64.1%)
Mutual labels:  uilabel
Ghosttypewriter
👻 A UILabel subclass that adds a typewriting animation effect
Stars: ✭ 159 (+307.69%)
Mutual labels:  uilabel
Zswtappablelabel
UILabel subclass for links which are tappable, long-pressable, 3D Touchable, and VoiceOverable.
Stars: ✭ 148 (+279.49%)
Mutual labels:  uilabel
android-material-design-in-practice
A project to demonstrate the latest material design principles with simple examples. It has additional examples on how to easily scale texts on different screen sizes without extra effort.
Stars: ✭ 67 (+71.79%)
Mutual labels:  font-scaling
Cjlabel
A drop-in replacement for UILabel that supports NSAttributedString, rich text, display any view, links, select copy and more
Stars: ✭ 140 (+258.97%)
Mutual labels:  uilabel
MarkNoteView
No description or website provided.
Stars: ✭ 23 (-41.03%)
Mutual labels:  uitextview
Swifticonfont
Icons fonts for iOS (Font Awesome 5, Iconic, Ionicon, Octicon, Themify, MapIcon, MaterialIcon, Foundation 3, Elegant Icon, Captain Icon)
Stars: ✭ 1,094 (+2705.13%)
Mutual labels:  uilabel
react-native-utils-scale
Provide solutions to make your app flexible for different screen sizes, different devices.
Stars: ✭ 38 (-2.56%)
Mutual labels:  font-scaling
GravityTagCloudView
A tag cloud view with gravity.
Stars: ✭ 22 (-43.59%)
Mutual labels:  uilabel
Uilabel Copyable
A simple category to add copy functionality to UILabel.
Stars: ✭ 113 (+189.74%)
Mutual labels:  uilabel
DossyTextLabel
A subclass of UILabel reminiscent of Strong Bad's faithful Tandy 400.
Stars: ✭ 75 (+92.31%)
Mutual labels:  uilabel
STTextView
📝 STTextView is a light-weight library that adds a placeholder to the UITextView.
Stars: ✭ 36 (-7.69%)
Mutual labels:  uitextview

AMXFontAutoScale

Twitter: @amaimescu License

Scale the font for UILabel and UITextView proportionally across all the screen sizes. Just define the screen size to be used as reference for scaling and the library will update all the instances of the UILabel and UITextView automatically.

Usage

  1. Set the UILabel or UITextView font using Interface Builder or the font property directly.
  2. Define for which labels and text views the font should be auto scaled. Check the examples below for more details.
  3. Define the reference screen size to be used for scaling. Your original font size will match exactly the chosen reference screen size and will be scaled up or down for other screen sizes.
  4. Enjoy the magic!
iPhone 4 inch iPhone 4.7 inch iPhone 5.5 inch
Contact List Contact Details Edit Contact

Usage examples

Define auto scaling for one instance

Define the reference screen size for a specific label. Different instances can have different reference screen sizes defined:

import AMXFontAutoScale

class SomeViewController: UIViewController {
    
    @IBOutlet var someLabel
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        someLabel.amx_autoScaleFont(forReferenceScreenSize: .size4Inch)
    }
}

Define auto scaling for multiple instances

In practice most of the instances will share the same reference screen size, so it is inconvenient to set it per instance. You can define the global reference screen size and just enable the auto scaling for particular instances:

import AMXFontAutoScale

class SomeViewController: UIViewController {
    
    @IBOutlet var someLabel1
    @IBOutlet var someLabel2
    @IBOutlet var someLabel3
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
	UILabel.amx_referenceScreenSize = .size4Inch
	
        someLabel1.amx_autoScaleEnabled = true
	someLabel2.amx_autoScaleEnabled = true
	someLabel3.amx_autoScaleEnabled = true
    }
}

Or using the Interface Builder:

Interface Builder

🌍 Define global auto scaling

⚠️ - Be careful when using this one as it literally scales all the instances of UILabel and UITextView from your app, even the unobvious labels or text views in the system controls and components.

import AMXFontAutoScale

class AppDelegate: UIResponder, UIApplicationDelegate {

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        // Scale all the label fonts using the 4 inch screen size as a reference
        UILabel.amx_autoScaleFont(forReferenceScreenSize: .size4Inch)
        
        return true
  }
}

Note: The instance scaling overrides the global one if set.

Disable scaling for some instances when global scaling is enabled

import AMXFontAutoScale

class SomeViewController: UIViewController {
    
    @IBOutlet var someLabel
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Global font scaling is enabled
	UILabel.amx_autoScaleFont(forReferenceScreenSize: .size4Inch)
	
        // Font scaling for someLabel is disabled
	// Alternatively you can disable it using the Interface Builder 
        someLabel.amx_autoScaleEnabled = false
    }
}

Handle manually font size updates

Get a closure called every time the font should be updated. Might be convenient when defining the fonts for the attributed strings:

import AMXFontAutoScale

class SomeViewController: UIViewController {
        
    override func viewDidLoad() {
        super.viewDidLoad()
        
        someLabel.amx_fontSizeUpdateHandler = { originalSize, preferredSize, multiplier in
	    // E.g. Compute the new fonts for the attributed text
        }
    }
}

Installation

CocoaPods

If you are using CocoaPods, you can as well use it to integrate the library by adding the following lines to your Podfile.

use_frameworks!

target 'YourAppTarget' do
    pod "AMXFontAutoScale"
end

Carthage

If you are using Carthage, you can always use it to build the library within your workspace by adding the line below to your Cartfile.

github "alexmx/AMXFontAutoScale"

Manual installation

In order to include the AMXFontAutoScale library into your project, you need to build a dynamic framework from provided source code and include it into your project, or include the entire AMXFontAutoScale library as sub-project by copying it to your project directory or include as git submodule.

License

This project is licensed under the terms of the MIT license. See the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].