Ignoring the dynamic type in iOS: Accessibility

后端 未结 4 1927
慢半拍i
慢半拍i 2020-12-10 14:19

Is there a way to completely ignore dynamic type/font size settings in iOS apps? I mean is there a way like a plist entry so that I can disable it completely. I understand t

4条回答
  •  猫巷女王i
    2020-12-10 14:31

    There's no need to swizzle UIApplication. Just subclass UIApplication and provide your own implementation of preferredContentSizeCategory:

    Swift:

    class MyApplication: UIApplication {
    
        override var preferredContentSizeCategory: UIContentSizeCategory {
            get { return UIContentSizeCategory.large }
        }
    }
    
    UIApplicationMain(
        CommandLine.argc,
        CommandLine.unsafeArgv,
        NSStringFromClass(MyApplication.self),
        NSStringFromClass(AppDelegate.self)
    )
    

    Objective-C:

    @interface MyApplication : UIApplication
    @end
    
    @implementation MyApplication
    
    - (UIContentSizeCategory) preferredContentSizeCategory
    {
        return UIContentSizeCategoryLarge;
    }
    
    @end
    
    int main(int argc, char * argv[]) {
        @autoreleasepool {
            return UIApplicationMain(argc, argv, NSStringFromClass([MyApplication class]), NSStringFromClass([AppDelegate class]));
        }
    }
    

提交回复
热议问题