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

Микроинтеракции в iOS

CocoaHeads
September 29, 2018

Микроинтеракции в iOS

CocoaHeads

September 29, 2018
Tweet

More Decks by CocoaHeads

Other Decks in Programming

Transcript

  1. class CALayer: NSObject { override func setValue(_ value: Any?, forKey

    key: String) } layer.setValue(true, forKey: “isActive”) CALayer как хранилище состояний
  2. class CALayer { var style: [AnyHashable: Any]? { get set

    } } CALayer как хранилище состояний
  3. class CALayer { func value(forKey key: String) -> Any? }

    style.key ?? style.style.key ?? style.style.style.key … CALayer как хранилище состояний
  4. protocol CAAction { func run(forKey event: String, object anObject: Any,

    arguments dict: [AnyHashable : Any]?) } Действия CAAction
  5. extension UIView: CALayerDelegate { func action(for layer: CALayer, forKey event:

    String) -> CAAction? { ... } } Действия CAAction
  6. class CALayer { func action(forKey event: String) -> CAAction? {

    let action = delegate.action(for: self, forKey: event) ?? actions[event] ?? style.actions[event] ?? style.style.actions[event] ?? ... CALayer.defaultAction(forKey: event) return action == NSNull() ? nil : action } } Действия CAAction
  7. view.backgroundColor = red { didSet { layer.backgroundColor = red }

    } Анимация хранимых свойств
  8. layer.backgroundColor { action = self.action(forKey: backgroundColor) self.storage.backgroundColor = red action.run(forKey:

    backgroundColor, object: self, arguments: nil) } Анимация хранимых свойств
  9. 53 › В блоке анимации анимируется › Вне блока анимации

    не анимируется Анимация хранимых свойств
  10. extension UIView: CALayerDelegate { func action(for layer: CALayer, forKey event:

    String) -> CAAction? { ... } } Действия CAAction
  11. class CALayer { func setValue(_ value: Any?, forKey key: String)

    { action = action(forKey: key) storage[key] = value action.run(forKey: key, object: self, arguments: nil) } } Анимация хранимых свойств
  12. class CALayer { func setValue(_ value: Any?, forKey key: String)

    { action = action(forKey: key) storage[key] = value action.run(forKey: key, object: self, arguments: nil) } } Анимация событий
  13. class CustomView { func activate() { action = layer.action(forKey: activate)

    action.run(forKey: activate, object: layer, arguments: nil) } } Анимация событий
  14. class Loader: UIView { var isActive: Bool // activate, deactivate

    var progress: Double // updateProgress // kCAOnOrderIn // kCAOnOrderOut } Лоадер