This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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, height: 175) |
This file contains hidden or 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 customController = CustomViewController() | |
| familyController.addChildViewController(customController, view: { $0.scrollView }) |
This file contains hidden or 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 | |
| let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) | |
| let view = UIView(frame: frame) | |
| view.backgroundColor = UIColor.blue |
This file contains hidden or 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 Cocoa | |
| let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) | |
| let view = NSView(frame: frame) | |
| view.wantsLayer = true | |
| view.layer?.backgroundColor = NSColor.blue.cgColor |
This file contains hidden or 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 | |
| class MyViewController: UIViewController {} | |
| let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) | |
| let viewController = MyViewController() | |
| viewController.view.frame = frame |
This file contains hidden or 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 Cocoa | |
| class MyViewController: NSViewController {} | |
| let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) | |
| let viewController = MyViewController() | |
| viewController.view.frame = frame |