Ignore Dynamic Type in iOS: Availability

Is there a way to completely ignore dynamic type / font size settings in iOS apps? I mean, there is a way similar to writing plist so that I can completely disable it. I understand that there is a notification that we can observe and reconfigure the font whenever changes to the settings occur. I am looking for a simpler solution. I am using iOS8. Thanks.

+8
ios accessibility iphone ios8
source share
3 answers

A quick equivalent to @ sense-of-things answer is as follows:

In the AppDelegate app:

@objc func swizzled_preferredContentSizeCategory() -> UIContentSizeCategory { return UIContentSizeCategory.small } open func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let originalMethod = class_getInstanceMethod(UIApplication.self, #selector(preferredContentSizeCategory)) let swizzledMethod = class_getInstanceMethod(UIApplication.self, #selector(swizzled_preferredContentSizeCategory)) method_exchangeImplementations(originalMethod, swizzled_preferredContentSizeCategory) } 
+2
source share

In AppDelegate add:

 #import <objc/runtime.h> @implementation AppDelegate NSString* swizzled_preferredContentSizeCategory(id self, SEL _cmd) { return UIContentSizeCategoryLarge; // Set category you prefer, Large being iOS' default. } - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { Method method = class_getInstanceMethod([UIApplication class], @selector(preferredContentSizeCategory)); method_setImplementation(method, (IMP)swizzled_preferredContentSizeCategory); ... } 
+1
source share

Just provide the Swift 4 patch for @ gebirgsbärbel's answer . "prefeContentSizeCategory" in Objective-C is a method, but in Swift it is a read-only variable. So, in your AppDelegate, it looks like this:

 @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? // MARK: - UIApplicationDelegate func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { UIApplication.classInit self.window = UIWindow(frame: UIScreen.main.bounds) ... self.window?.makeKeyAndVisible() return true } } // MARK: - Fix Dynamic Type extension UIApplication { static let classInit: Void = { method_exchangeImplementations( class_getInstanceMethod(UIApplication.self, #selector(getter: fixedPreferredContentSizeCategory))!, class_getInstanceMethod(UIApplication.self, #selector(getter: preferredContentSizeCategory))! ) }() @objc var fixedPreferredContentSizeCategory: UIContentSizeCategory { return .large } } 
0
source share

All Articles