1. Private KVC

[self setValue:baseTabBar forKey:@"tabBar"]; / / normal [_textFieldsetValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"]; / / / collapse [_textFieldsetValue:[UIFont systemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"]; / / / collapse _textField. AttributedPlaceholder = [[NSAttributedString alloc] initWithString: @"Name"attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor redColor]}]; /// New implementationCopy the code

Compiling on Xcode10 will be fine, but compiling on Xcode11 will crash. – (void)setValue:(nullable id)value forKey:(NSString *)key – (void)setValue:(nullable id)value forKeyPath:(NSString *)keyPath crashes

2. PresentViewController problem

This happens mainly because we didn’t set the required type for one of the properties in UIViewController, modalPresentationStyle, which is the style the controller will use in its modal view. In iOS13 modalPresentationStyle default UIModalPresentationAutomatic instead, in previous default is UIModalPresentationFullScreen.

This is not affected by the Xcode version, as long as the system is iOS13 and does not explicitly set the modalPresentationStyle, this problem will occur

3. The soon-to-be-abandoned LaunchImage

Since iOS 8, apple has introduced the LaunchScreen, which we can set up as the LaunchScreen. Of course, now you can also use LaunchImage to set up the LaunchImage. With LaunchImage, however, we have to provide launch images of various screen sizes to fit all devices, which is obviously not Flexible enough as Apple devices get bigger and bigger. LaunchScreen supports AutoLayout+SizeClass, so it’s easy to fit all kinds of screens. Note ⚠️, starting in April 2020, all apps using the iOS13 SDK will be required to provide the LaunchScreen, and the LaunchImage will be phased out

4. Dark Mode

The principle of

1. Create two patterns from the same resource. The system automatically obtains resources of the selected style

2. Every time the system updates the style, the application will call all the existing elements and call some corresponding re-methods to redraw the view, and you can make corresponding changes in the corresponding methods

Resource file adaptation

1. Create an Assets file (or an existing Assets file) 2. Create a new image resource file (or color resource file, or other resource file) 3. Check the resource file and open the Xcode ->View ->Show Attributes Inspectors (or Option+Command+4) View to change the Apperances Option to Any, Dark 4. At the end of step 3, the resource file will have several container boxes, named Any Apperance and Dark Apperance. Any Apperance applies to Unspecified and Light. Dark Apperance applies to Dark mode 5. When the code is executed by default, it can be used normally by name, and the system will automatically obtain the corresponding resource file according to the current mode

Pay attention to

After multiple Assets files are packaged in the same project, an assets. car file is generated. Therefore, ensure that the names of asset files are different

UIView

traitCollectionDidChange(_:)
layoutSubviews()
draw(_:)
updateConstraints()
tintColorDidChange()
Copy the code

UIViewController

traitCollectionDidChange(_:)
updateViewConstraints()
viewWillLayoutSubviews()
viewDidLayoutSubviews()
Copy the code

UIPresentationController

traitCollectionDidChange(_:)
containerViewWillLayoutSubviews()
containerViewDidLayoutSubviews()
Copy the code

Turn off dark mode globally

  • Method 1 Configuring the PList file: In the info.plist file, add UIUserInterfaceStyle key with the name UserInterfaceStyle value String and set the value of UIUserInterfaceStyle key to Light

In the development, if the system control (such as cell, tableView background color) is not set background color (or transparent), after entering the dark mode, the control background color turns black.

It can be set for each page, of course, it can also be set as a whole. Generally, our APP is under a window, so set the window in the APP as a whole

  • Mode 2: Code Off Dark Mode Forcibly turns off dark mode
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if(@ the available (iOS 13.0. *)) {self. Window. OverrideUserInterfaceStyle = UIUserInterfaceStyleLight; }#endif
Copy the code

Individual interfaces do not follow dark mode

  1. UIViewController and UIView overrideUserInterfaceStyle a new attribute

  2. Sets the overrideUserInterfaceStyle to corresponding mode, mandatory limit on the element and its child elements to the set mode to display, do not follow the system model change to change

    1. Setting this property on the ViewController will affect the ViewController’s views and child view controllers to adopt this style
    2. Setting this property on the View will affect the style of the View and all its children
    3. Setting this property for the Window will style everything in the Window, including the root view controller and all presentation controllers (UIPresentationControllers) that display content in the Window.

IOS adapter diablo mode: www.jianshu.com/p/7925bd51d…

5. Add the permission application for using Bluetooth all the time

CBCentralManager, iOS13 before, when using Bluetooth can be used directly, there will not be a permission prompt, iOS13, then use will be prompted. Add it to info.plist

< key > NSBluetoothAlwaysUsageDescription < / key > < string > we want to continue to use your bluetooth, specific what to do don't ask me < / string > `Copy the code

6. Handle nULL differences using MJExtension

Mj_JSONObject (class_copyPropertyList) {EFSQLBinding () {class_copyPropertyList (); And the number of properties isn’t exactly right, so there’s nothing I can do about it, so I’m going to have to rewrite this method, write a method swizzling without updating this component and then when it hits NSNull, it goes straight to nil.

7. WKWebView changes the way to measure page content height

IOS document before 13. Body. ScrollHeight iOS 13 document. The documentElement. ScrollHeight both differ 55 should be a browser definition level changed

8. Umu message push to obtain deviceToken adaptation

- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
   if(! [deviceToken isKindOfClass:[NSData class]])return;
      const unsigned *tokenBytes = (const unsigned *)[deviceToken bytes];
      NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),ntohl(tokenBytes[6]),ntohl(tokenBytes[7])];
      pushDeviceToken = hexToken;
      NSLog(@"deviceToken:%@",hexToken);
}
Copy the code

9. StatusBar is different from previous versions

At present, a new mode is added to the status bar, which has been changed from two to three. The default mode is changed from black content to automatically selecting lightContent or darkContent to be displayed according to the system mode

10. The Crash caused by fishhookGithub.com/facebook/fi…