• This repository has been archived on 04/Jul/2018
  • Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

BNRDynamicTypeManager

Version Platform Build Status

BNRDynamicTypeManager is a collection of helper classes that make it easier to use Dynamic Type in iOS 7 applications. Most importantly, it handles listening for UIContentSizeCategoryDidChangeNotification and updating the fonts of all "watched" views automatically.

To run the example project, clone the repo, make sure the Example target is selected, and run it.

To run the unit tests, run pod install from the Tests directory first.

Usage - XIB Files and Storyboards

The simplest use case is if your are using XIB files or storyboards. After pulling BNRDynamicTypeManager into your project, change any instances of the following classes to the appropriate BNRDynamicTypeManager-provided subclasses (and make sure that one of the system Text Styles is selected as the view's font):

  • UILabel โ†’ BNRDynamicTypeManagedLabel
  • UIButton โ†’ BNRDynamicTypeManagedButton
  • UITextField โ†’ BNRDynamicTypeManagedTextField
  • UIView โ†’ BNRDynamicTypeManagedView

Usage - Programmatic View Creation

If you are creating views programmatically, use the same class mapping from Using XIB Files above, and use the designated initializer from their header files. The initializers have the same arguments as the UIKit parents with an additional textStyle: argument. For example, creating a managed UILabel and UITextView:

#include <BNRDynamicTypeManager/BNRDynamicTypeManagedLabel.h>
#include <BNRDynamicTypeManager/BNRDynamicTypeManagedButton.h>
#include <BNRDynamicTypeManager/BNRDynamicTypeManagedTextField.h>
#include <BNRDynamicTypeManager/BNRDynamicTypeManagedTextView.h>

UILabel *label = [[BNRDynamicTypeManagedLabel alloc]
                       initWithFrame:CGRectZero
                           textStyle:UIFontTextStyleBody];
UIButton *button = [[BNRDynamicTypeManagedButton alloc]
                         initWithFrame:CGRectZero
                             textStyle:UIFontTextStyleBody];
UITextField *textField = [[BNRDynamicTypeManagedTextField alloc]
                               initWithFrame:CGRectZero
                                   textStyle:UIFontTextStyleFootnote];
UITextView *textView = [[BNRDynamicTypeManagedTextView alloc]
                             initWithFrame:CGRectZero
                             textContainer:nil
                                 textStyle:UIFontTextStyleFootnote];

Usage - Without UIKit Subclasses

If you want more explicit control (e.g., if you already have a UIKit subclass that you're using, but you'd still like to have the font managed for you), use BNRDynamicTypeManager directly by telling it what objects to watch. If the object is one of the known UIKit classes or a subclass of them, use the provided methods. E.g., for UILabel:

#include <BNRDynamicTypeManager/BNRDynamicTypeManager.h>

UILabel *label = /* create a label */;

// Tell BNRDynamicTypeManager to update label.font now and any time the user
// changes their font size.
[[BNRDynamicTypeManager sharedInstance] watchLabel:label
                                         textStyle:UIFontTextStyleBody];

If you want to watch an object that isn't one of the known UIKit classes, but has a UIFont *font that can be reached via a keypath, use watchElement:fontKeypath:textStyle: instead. E.g., if there wasn't a method provided for UIButton:

#include <BNRDynamicTypeManager/BNRDynamicTypeManager.h>

UIButton *button = /* create a button */;

[[BNRDynamicTypeManager sharedInstance] watchElement:button
                                         fontKeypath:@"titleLabel.font"
                                           textStyle:UIFontTextStyleBody];

Requirements

iOS 7 and ARC.

Installation with Cocoapods

BNRDynamicTypeManager is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "BNRDynamicTypeManager", "~> 0.1.0"

Installation without Cocoapods

Grab the class files (header and implementation) from the BNRDynamicTypeManager/Core and BNRDynamicTypeManager/Controls directory and copy them into your project.

Author

John Gallagher, [email protected]

License

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

More Repositories

1

expandable-recycler-view

[DEPRECATED]
Java
1,215
star
2

Freddy

A reusable framework for parsing JSON in Swift.
Swift
1,090
star
3

CoreDataStack

The Big Nerd Ranch Core Data Stack
Swift
562
star
4

Deferred

Work with values that haven't been determined yet.
Swift
421
star
5

developing-alexa-skills-solutions

JavaScript
232
star
6

why_elixir

Selling points for Elixir / Phoenix
155
star
7

Typesetter

Android tool to help display changes to text positioning.
Java
150
star
8

iOS7Demos

Some short demos of new stuff in iOS 7
Objective-C
145
star
9

android-bluetooth-testbed

Provides a Server and Client example for understanding Bluetooth Low Energy on Android
Java
97
star
10

music-frequency-d3

A music frequency visualizer using D3.js
JavaScript
93
star
11

rust-ios-app-part-1

Let's Build an iOS App in Rust, part 1
Swift
81
star
12

iOS8Demos

iOS 8 release day demonstrations
Objective-C
77
star
13

AndroidCourseResources

Resources for our Android Bootcamp.
Java
75
star
14

stockwatcher

stockwatcher, a modern android development stack showcase
Java
62
star
15

alexa-airportinfo

Node.js src for the article "Developing Alexa Skills Locally with Node.js"
JavaScript
61
star
16

bnns-cocoa-example

An example of a neural network trained by tensorflow and executed using BNNS
Objective-C
59
star
17

type-erasure-playgrounds

Code to accompany Swift Symposium Talk - https://www.youtube.com/watch?v=d_FJHBl5ohU
Swift
56
star
18

Result

Small Swift library for Result type
Swift
47
star
19

android-listview-custom-view

Example of using a custom view subclass with ListView and a custom Adapter
Java
45
star
20

linette

Custom lint checks for Android development.
Java
42
star
21

rust-ios-app-part-3

Let's Build an iOS App in Rust, part 3
Swift
31
star
22

iOS3eSolutions

Solutions to iOS Programming: The Big Nerd Ranch Guide, 3rd Edition.
Objective-C
31
star
23

doze-logger

Simple app thrown together to help demonstrate the effects of doze mode on your background schedulers.
Java
30
star
24

ScriptableTextEditor

A simple Cocoa text editor that demonstrates creating a plugin system in Python.
Objective-C
29
star
25

DeferredTCPSocket

DeferredTCPSocket is a Swift framework for asynchronous TCP networking.
Swift
28
star
26

macOS-bootstrap

A bootstrap script for configuring machine to develop iOS, tvOS, and macOS apps
Shell
25
star
27

BNR-blog-cameraxMlkit

Sample project associated with blog post on using Firebase MLKit with CameraX.
Kotlin
21
star
28

blog-ios-xcui-todo

Demonstrates using Xcode 7's new UI testing support
Swift
20
star
29

BNRun-SiriKit-Sample

Sample code for the SiriKit blog post
Swift
19
star
30

Roger

Roger is jolly. By Franklin.
Objective-C
18
star
31

controllers-for-tvOS

Sample app for tvOS that reads game controllers
Swift
18
star
32

jenkins-android-signing

[DEPRECATED] Jenkins Plugin for signing Android APKs
Java
18
star
33

alexa-account-linking-service

Code example for the Oauth account linking example for an alexa skills
JavaScript
17
star
34

tensorflow-cocoa-example

Using tensorflow inside a desktop Cocoa application
Python
17
star
35

ViewRotationTest

A demonstration of various techniques for view rotation in Cocoa Touch.
Objective-C
17
star
36

BlappyFird

Demo clone of a popular game
Swift
16
star
37

rust-ios-app-part-2

Let's Build an iOS App in Rust, part 2
Swift
12
star
38

rust-ios-app-part-4

Let's Build an iOS App in Rust, part 4
Rust
12
star
39

react-testing-workshop

Starter Code for BNR React Testing Workshop
JavaScript
11
star
40

BNRXIBCell

A UITableViewCell subclass, intended to be subclassed, to forward action messages from cell subviews to a controller.
Objective-C
11
star
41

opencv-cocoa-example

An example of using OpenCV in a Cocoa application
Objective-C++
10
star
42

BNR-blog-motionlayout

Sample project associated with blog post on using MotionLayout and MotionEditor.
Kotlin
9
star
43

semaphorejs

A functional-style Semaphore for managing concurrent access to a resource. For JavaScript.
JavaScript
9
star
44

RanchWeather

A demo app written in Swift 3 to demonstrate different code patterns.
Swift
9
star
45

android-securebank

Code example companion for the DevNexus talk: "Keeping Android Secrets Secure with Fingerprint Authentication and the Keystore"
Java
8
star
46

ember-engine-example

Ember-Engine Example: Large Company Site from Blogpost
JavaScript
8
star
47

dexie-fulltextsearch

Full text search for IndexedDB databases, powered by Dexie.
JavaScript
8
star
48

id3-meta

A metadata parser for ID3v2 formatted MP3s, in JavaScript.
JavaScript
8
star
49

SyncAdapterDemo

Experiment with android sync adapters. Getting them to work with a remote rails server to sync book error data.
Java
8
star
50

iOS-Responsive-UI-Sample

3 examples examining modern techniques for making iOS app UI accessible and responsive.
Swift
7
star
51

OpenParentApplicationDemo

Demo of openParentApplication method of WatchKit
Swift
7
star
52

doktor-demo

A simple Ktor demo app. Write Kotlin on the server.
Kotlin
7
star
53

BNRLoupe

A magnifying loupe for images that displays one-for-one pixel information for the point under the finger.
Objective-C
7
star
54

permission-manager

Easily and seamlessly ask for Android runtime permissions.
Java
7
star
55

alexa-cakebaker

JavaScript
7
star
56

cocoa-conf-stack-views

@cbkeur's CocoaConf talk on UIStackViews
Swift
6
star
57

character-data-api

Kotlin Ktor backend for the Samodelkin Android Client
Kotlin
6
star
58

meta_elixir

Elixir
5
star
59

cleaning-up-messy-chaining-code-in-swift

Swift
5
star
60

ShindigSheriff

Event Manager Manager, Mr. Manager
Ruby
5
star
61

auto-layout-mastery-conference-talk-2016

Step's Auto Layout Mastery talk about Priorities
Swift
4
star
62

upfront

Go
4
star
63

ottergram-solutions

Sample of how we could organize solutions for the 4 apps in the frontend book.
4
star
64

FocusWheel

A tvOS app for a two-part Big Nerd Ranch Blog Post on collection view layouts and the focus engine
Swift
4
star
65

Github-Issues-Reader

A super cool app for reading github issues that definitely doesn't already exist
Swift
3
star
66

cocoa-layout-instrument-demo

Sample files to accompany a blog post on the Cocoa Layout Instrument.
Swift
3
star
67

BNR-react-native-style-queries

Declarative responsive design for React Native.
JavaScript
3
star
68

bootstrap

Ruby
3
star
69

SocialDistancingSimulator

A SpriteKit-based social distancing simulator
Swift
3
star
70

auto-layout-priorities-2016

Demo project that accompanies Auto Layout Mastery Conference Talk on priorities from Step Christopher
Swift
3
star
71

alfred_reflecticle_extension

Ruby
2
star
72

KotlinConf2023-TestRefactor

Kotlin 2023 Testing Workshop Template
Kotlin
2
star
73

tacostand

A sample project for practice using Rails applications
Ruby
2
star
74

authorizing-jsonapi-resources

A tutorial for protecting private resources in JSONAPI::Resources.
Ruby
2
star
75

BNR-blog-React-to-Vue-react-simple

React project for comparison to Vue for blog entry
JavaScript
2
star
76

vapor-testing-example

Demonstrates testing techniques in the Vapor framework
Swift
2
star
77

bnr-webhooks

Big Nerd Ranch's webhook layer for inter-service communication.
Ruby
2
star
78

cardo

DSL for creating recurring Pivotal Tracker stories
Ruby
2
star
79

ember-engine-external-admin

Ember-Engine Example: External Admin
JavaScript
2
star
80

html5-course-ajax-dummy

Just a dummy AJAX endpoint for the HTML5 course.
Ruby
2
star
81

CrashTest

UIKit Dynamics Playground
Objective-C
2
star
82

KotlinConf2023-ContextReceivers

The supporting code for Bryan Sills's talk titled "Introduction To Context Receivers" at KotlinConf 2023
Kotlin
2
star
83

constraints_experiments

Some experiments for a blog post
Elixir
2
star
84

BNR-graphql-java-samples

Holds some meaningful examples of building GraphQL API's in Java.
Java
2
star
85

nybblr-javascript-book-walkthrough

My run through of the frontend dev book.
JavaScript
2
star
86

AtomicSwift

Objective-C
1
star
87

BNR-blog-React-to-Vue-vue-simple

Vue project for comparison to React for blog entry
Vue
1
star
88

gatsby-twenties-tribute

A tribute page to the twenties built with Gatsby.js
CSS
1
star
89

ml-boston-pricer

A repo for hosting the demo project for BNR's Core ML blog post.
Swift
1
star
90

service-object-testing-example

Java
1
star
91

devnulldb

:trollface: MySQL server
JavaScript
1
star
92

clash_of_the_coders

Site for Clash of the Coders scoreboard
Ruby
1
star
93

omniauth-stable

Omniauth Strategy for Stable
Ruby
1
star
94

KotlinConf2023-ComposeForDesktop

The supporting code for Bryan Sills's codelab titled "Compose For Desktop" at KotlinConf 2023
Kotlin
1
star
95

RubyCourseResources

Files and helpful info associated with the Ruby portion of our Beginning Ruby on Rails Bootcamp.
1
star
96

carkeeper

Sample code accompanying @lyricsboy's talk "Applying the Single Responsibility Principle in iOS"
Objective-C
1
star
97

ios-ci-example

Example Distribution for the Travis CI Integration of a sample app
Objective-C
1
star
98

TableCollectionView

Handful of classes that make it easier to use a Collection View as a replacement for a Table View
1
star
99

iOS-Win8-Seminar-Public

Files for use in the exercises of the "Windows Store Development for iOS Developers" seminar.
1
star
100

iOSCourseResources

1
star