Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Александр Зимин - Как мы поддерживали In-Call Status Bar и адаптировали Badoo под iPhone X

CocoaHeads
November 10, 2017

Александр Зимин - Как мы поддерживали In-Call Status Bar и адаптировали Badoo под iPhone X

CocoaHeads

November 10, 2017
Tweet

More Decks by CocoaHeads

Other Decks in Programming

Transcript

  1. О нас 350m Сообщений в день 350m Зарегистрированных пользователей 60m

    Ежемесячная аудитория 300k Регистраций в день
  2. • Что такое In-Call Status Bar • Наш опыт “сражения”

    с ним • Дизайн под iPhone X • Наш опыт адаптации под него План
  3. Экран загрузки Решения 1. Прятать status bar во время запуска

    2. Использовать LaunchScreen.storyboard 3. Не рисовать контент по середине https://goo.gl/Wmb8XS
  4. - (UIWindow *)mainWindow { if (!_mainWindow) { _mainWindow = [[[UIApplication

    sharedApplication] delegate] window]; } return _mainWindow; } // ... self.contentContainerView.bma_height = self.mainWindow.bma_height - menuViewHeight // ...
  5. let redVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: “VC") self.addChildViewController(redVC) self.view.addSubview(redVC.view)

    redVC.didMove(toParentViewController: self) redVC.view.translatesAutoresizingMaskIntoConstraints = false redVC.view.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true redVC.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true redVC.view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor).isActive = true
  6. window?.backgroundColor = UIColor.white class FirstViewController: UIViewController { } class MidleViewController:

    UIViewController { override var prefersStatusBarHidden: Bool { return true } } class LastViewController: UIViewController { override var prefersStatusBarHidden: Bool { return false } @IBAction func backAction(_ sender: Any) { self.dismiss(animated: true, completion: nil) } }
  7. Тут, возможно, будет видео гличей без In-call status bar, которые

    мы получили, прееехав на публичные методы
  8. public extension UIWindow { // https://openradar.appspot.com/2443851 func bma_forceAdjustmentsOfViews(isStatusBarHidden: Bool) {

    guard StatusBarManager.shared.isInCallStatusBar else { return } for view in self.subviews { self.adjustFrame(of: view, isStatusBarHidden: isStatusBarHidden, baseView: self) } self.forceAdjustmentsOfViewsRecursevly(isStatusBarHidden: isStatusBarHidden, baseView: self) } }
  9. fileprivate func forceAdjustmentsOfViewsRecursevly(isStatusBarHidden: Bool, baseView: UIView) { for view in

    self.subviews { if view.isTransitionView { self.adjustFrame(of: view, isStatusBarHidden: isStatusBarHidden, baseView: baseView) } view.forceAdjustmentsOfViewsRecursevly(isStatusBarHidden: isStatusBarHidden, baseView: baseView) } }
  10. fileprivate func adjustFrame(of view: UIView, isStatusBarHidden: Bool, baseView: UIView) {

    if isStatusBarHidden { view.frame = baseView.bounds } else { let inCallStatusBarOffset = StatusBarManager.shared.inCallStatusBarOffset view.frame = CGRect(x: 0, y: inCallStatusBarOffset, width: baseView.bounds.width, height: baseView.bounds.height - inCallStatusBarOffset) } }
  11. public func bma_adjustTopMarginToFitSafeAreaAndStatusBarOnOldVersions() { if #available(iOS 11.0, *) { }

    else { var margins = self.layoutMargins let oldStatusBarSpace: CGFloat = 20 margins.top = oldStatusBarSpace self.layoutMargins = margins } } - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; [self.view bma_adjustTopMarginToFitSafeAreaAndStatusBarOnOldVersions]; } https://twitter.com/ZiminAlex/status/920012746321747969
  12. Window RootVC View top: 44 bottom: 34 top: 44 bottom:

    34/0 Window RootVC View RootVC View top: 44 bottom: 34 top: 44 bottom: 34/0
  13. Window RootVC View top: 20 bottom: 0 top: 0 bottom:

    0 https://twitter.com/ZiminAlex/status/918534774477778944
  14. Window RootVC View top: 44 bottom: 34 top: 44 bottom:

    34/0 Window RootVC View RootVC View top: 44 bottom: 34 top: 44 bottom: 34/0
  15. public var bpui_keyWindowSafeAreaInsets: UIEdgeInsets? { if #available(iOS 11.0, *) {

    let windowInsets = self.keyWindow?.safeAreaInsets var rootViewSafeAreaInsets = self.keyWindow?.rootViewController?.view.safeAreaInsets rootViewSafeAreaInsets?.bottom = windowInsets?.bottom ?? rootViewSafeAreaInsets?.bottom ?? 0 return rootViewSafeAreaInsets } return nil }
  16. • Проверьте свои input view • Проверьте xib’ы • Места

    с хардкором решаются легко, но их сложно найти • Свой TabBar упростил нам жизнь • Есть и частные ситуации (полный профиль) • Подумайте как закрашивать плашки внизу • С рекламой все грустно Итоги
  17. • iOS Safe Area — https://medium.com/rosberryapps/ios-safe-area-ca10e919526f • Update your apps

    for iPhone X — https://developer.apple.com/ios/update-apps- for-iphone-x/ • Challenges of Supporting iPhone X — https://pspdfkit.com/blog/2017/ supporting-iphone-x/ • Updating Your App for iOS 11 — https://developer.apple.com/videos/play/ wwdc2017/204/ • What's New in Cocoa Touch — https://developer.apple.com/videos/play/ wwdc2017/201/