This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let familyController = FamilyViewController() | |
let viewController = UIViewController() | |
familyController.addChildViewController(viewController) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let animationDuration: TimeInterval? = subviewsInLayoutOrder | |
.flatMap({ $0.layer.resolveAnimationDuration }).first ?? duration | |
if let duration = animationDuration { | |
let options: UIViewAnimationOptions = [.allowUserInteraction, .beginFromCurrentState] | |
UIView.animate(withDuration: duration, delay: 0.0, options: options, animations: { | |
self.runLayoutSubviewsAlgorithm() | |
}) | |
} else { | |
runLayoutSubviewsAlgorithm() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension CALayer { | |
/// Resolve animation duration of the first animation using animation keys. | |
var resolveAnimationDuration: CFTimeInterval? { | |
if let firstKey = animationKeys()?.first, | |
let animation = animation(forKey: firstKey) { | |
return animation.duration | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let options: UIViewAnimationOptions = [.allowUserInteraction, .beginFromCurrentState] | |
UIView.animate(withDuration: 0.4, delay: 0.0, options: options, animations: { | |
self.headerViewController.view.frame.size.height = 120 | |
self.contentViewController.view.frame.size.height = 320 | |
self.moreViewController.view.frame.size.height = 210 | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let options: UIViewAnimationOptions = [.allowUserInteraction, .beginFromCurrentState] | |
UIView.animate(withDuration: 2.5, delay: 0.0, options: options, animations: { | |
self.runLayoutSubviewsAlgorithm() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let shouldAnimate = !(subviewsInLayoutOrder.flatMap{ $0.layer.animationKeys() }.isEmpty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Swift 4 version of https://gist.github.com/petergp/815ba3bf6b7280c2c01f | |
private class ImageView : UIImageView { | |
private class Layer: CALayer { | |
override func addSublayer(_ layer: CALayer) { | |
defer { super.addSublayer(layer) } | |
let cornerRadiusKey = "_cornerRadius" | |
guard let configuration = layer.value(forKey: "_configuration") as? NSObject, | |
configuration.responds(to: NSSelectorFromString(cornerRadiusKey)) else { | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func createRelatedComponents() -> [ComponentModel] { | |
let infoComponent = ComponentModel( | |
header: Item(title: "Star Wars films and television series", kind: Spots.Identifier.header), | |
kind: .grid, | |
layout: Layout(span: 1, inset: Inset(top: 0, left: 20, bottom: 30, right: 20)), | |
items: [Item(text: "The Star Wars films include two complete trilogies: the original trilogy released between 1977 and 1983, and the prequel trilogy released between 1999 and 2005. A third trilogy that follows the first two began in 2015. Other films have taken or will take place between the trilogy films. There have also been several Star Wars television series and television movies, with the first being released in 1978.", kind: Spots.Identifier.info)] | |
) | |
let relatedComponent = ComponentModel( | |
header: Item(title: "Related movies", kind: Spots.Identifier.header), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Spots | |
enum MainContentType: String { | |
case details, reception, related | |
} | |
class ContentFactory { | |
func sideComponents() -> [ComponentModel] { | |
let posterComponent = ComponentModel( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(lldb) bt | |
* thread #1: tid = 0x2276c8, 0x000000011265c75a libswiftFoundation.dylib`static Foundation.IndexPath._unconditionallyBridgeFromObjectiveC (Swift.Optional<__ObjC.NSIndexPath>) -> Foundation.IndexPath + 42, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) | |
* frame #0: 0x000000011265c75a libswiftFoundation.dylib`static Foundation.IndexPath._unconditionallyBridgeFromObjectiveC (Swift.Optional<__ObjC.NSIndexPath>) -> Foundation.IndexPath + 42 | |
frame #1: 0x000000010f7c1028 Spots`@objc Delegate.tableView(UITableView, didEndDisplaying : UITableViewCell, forRowAt : IndexPath) -> () + 88 at Delegate+iOS+Extensions.swift:0 | |
frame #2: 0x0000000110a43ba9 UIKit`-[UITableView _reuseTableViewCell:withIndexPath:didEndDisplaying:] + 294 | |
frame #3: 0x0000000110a3fca4 UIKit`-[UITableView _updateVisibleCellsNow:isRecursive:] + 2410 | |
frame #4: 0x0000000110a74f9f UIKit`-[UITableView _performWithCachedTraitCollection:] + 110 | |
frame #5: 0x0000000110a5bfc8 |