One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
| import UIKit | |
| /// A very simple example view that can accept keyboard input and add or delete text from an enclosed label. | |
| class CustomTextInputView : UIControl, UIKeyInput { | |
| var label : UILabel? | |
| override func canBecomeFirstResponder() -> Bool { | |
| return true | |
| } |
| protocol Initializable { | |
| init() | |
| } | |
| class A : Initializable { | |
| var content:String | |
| required init() { | |
| content = "TestContent" | |
| } |
| // #!Swift-1.1 | |
| import Foundation | |
| // MARK: - (1) classes | |
| // Solution 1: | |
| // - Use classes instead of struct | |
| // Issue: Violate the concept of moving model to the value layer | |
| // http://realm.io/news/andy-matuschak-controlling-complexity/ |
| // | |
| // DetailViewController.swift | |
| // TransitionCoordinator | |
| // | |
| // Created by Rob Nadin on 15/02/2015. | |
| // Copyright (c) 2015 Rob Nadin. All rights reserved. | |
| // | |
| import UIKit |
| extension UIImage { | |
| public func imageRotatedByDegrees(degrees: CGFloat) -> UIImage { | |
| let radiansToDegrees: (CGFloat) -> CGFloat = { | |
| return $0 * (180.0 / CGFloat(M_PI)) | |
| } | |
| let degreesToRadians: (CGFloat) -> CGFloat = { | |
| return $0 / (180.0 * CGFloat(M_PI)) | |
| } | |
| // calculate the size of the rotated view's containing box for our drawing space |
| // Requires macros: | |
| #define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI)) | |
| #define DEGREES_TO_RADIANS(angle) (angle / 180.0 * M_PI) | |
| - (UIImage *)imageRotatedByDegrees:(CGFloat)degrees | |
| { | |
| // calculate the size of the rotated view's containing box for our drawing space | |
| UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.size.width, self.size.height)]; | |
| CGAffineTransform t = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees)); |
| osascript -e 'tell application "iOS Simulator" to quit' | |
| osascript -e 'tell application "Simulator" to quit' | |
| xcrun simctl erase all |
In this article, I'm going to explore a way that we can create views that implement custom Core Animation property animations in a natural way.
As we know, layers in iOS come in two flavours: Backing layers and hosted layers. The only difference between them is that the view acts as the layer delegate for its backing layer, but not for any hosted sublayers.
In order to implement the UIView transactional animation blocks, UIView disables all animations by default and then re-enables them individually as required. It does this using the actionForLayer:forKey: method.
Somewhat strangely, UIView doesn't enable animations for every property that CALayer does by default. A notable example is the layer.contents property, which is animatable by default for a hosted layer, but cannot be animated using a UIView animation block.
| git clean -xfd | |
| git submodule foreach --recursive git clean -xfd | |
| git reset --hard | |
| git submodule foreach --recursive git reset --hard | |
| git submodule update --init --recursive |