Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MCE^3 - Marin Todorov - Building Swift Libraries for iOS

88 views

Published on

I'll look into the internals of a Swift library developed for iOS that heavily uses UIKit and the ObjectiveC runtime. Since those are two dependencies you can't get rid off why not make the best out of them? I'm going to look into how I could stand of the shoulders of giants to deliver a slim but flexible Swift lib with the ObjectiveC runtime blessing.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

MCE^3 - Marin Todorov - Building Swift Libraries for iOS

  1. 1. Building Swift Libraries for iOS Marin Todorov
  2. 2. Marin Todorov www.realm.io www.raywenderlich.com
  3. 3. Pure
  4. 4. JSONModel Thanks Objective-C runtime! SwiftBlah Types 😱
  5. 5. https://developer.apple.com/library/ios/documentation/Miscellaneous/Conceptual/iPhoneOSTechOverview/Introduction/Introduction.html
  6. 6. 15 projects —————— 5 w/ views 9 w/ layers 1 w/ pop
  7. 7. UIView animations
  8. 8. CALayer animations
  9. 9. Motivation How would I improve the built-in iOS animation APIs? 🤔
  10. 10. Goals * easier layer animations * easier animation sequences * layer spring animations
  11. 11. David Rönnqvist https://www.objc.io/issues/12-animations/view-layer-synergy/
  12. 12. UIView.animateWithDuration(1.0, animations: { }) Create an animation context Destroy the animation context Original animations block Animate layer properties
  13. 13. view.alpha = 0.5 layer.position.y = 200 layer.cornerRadius = 50 UIView.actionForLayer(layer, “alpha”) CAAnimation UIView.actionForLayer(layer, “position.y”) CAAnimation UIView.actionForLayer(layer, “cornerRadius”) NSNull
  14. 14. layer.cornerRadius = 50 CABasicAnimation(keyPath: “cornerRadius”) toValue = 50 fromValue = <current value> CALayerDelegateCALayer
  15. 15. Layer animations
  16. 16. Goals * easier layer animations * easier animation sequences * layer spring animations
  17. 17. UIView.animateWithDuration(1.0, animations: {
 first animation
 }).animateWithDuration(1.0, {
 second animation
 })… etc … Ideal Pseudo Code
  18. 18. Actual Code
  19. 19. Sequence animations
  20. 20. Goals * easier layer animations * easier animation sequences * layer spring animations
  21. 21. UIKit.animateWithDuration(…) CABasicAnimation UIKit.animateWithDuration(… springDamping: , springInitialVelocity: …) CASpringAnimation on iOS9 RBBSpringAnimation on iOS8 Basic vs Spring Animations
  22. 22. Gotchas * Premature completion!
 * What is a damped harmonic oscillator?
 * Retain/release #$!
  23. 23. http://ultradownloads.com.br/papel-de-parede/Meme-Freddie-Mercury/
  24. 24. Thank you! Marin Todorov mt@realm.io @icanzilb www.underplot.com

×