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
| extension GameController: MemoryGameProtocol { | |
| func memoryGameDidStart(_ game: MemoryGame) { | |
| collectionView.reloadData() | |
| } | |
| func memoryGame(_ game: MemoryGame, showCards cards: [Card]) { | |
| for card in cards { | |
| guard let index = game.indexForCard(card) | |
| else { continue | |
| } |
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
| UIView.animate(withDuration: 2.0, animations: { () -> Void in | |
| // Move "appleImage" from current position to center | |
| appleImage.center = containerView.center | |
| // Change current background color to white | |
| circle.backgroundColor = UIColor.white | |
| }) |
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 translate = CGAffineTransform(translationX: 100, y: 100) | |
| let rotate = CGAffineTransform(rotationAngle: 360) | |
| let scale = CGAffineTransform(scaleX: 5, y: 5) | |
| //You can even combine 2 animations together. | |
| circle.transform = translate.concatenating(rotate) |
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
| class Responder : NSObject { | |
| func action() { | |
| // On click | |
| } | |
| } | |
| let responder = Responder() | |
| let gesture = UITapGestureRecognizer( | |
| target: responder, | |
| action: #selector(Responder.action) | |
| ) |
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
| UIView.animate( | |
| withDuration: 0.5, | |
| delay: 0, | |
| usingSpringWithDamping: 0.7, | |
| initialSpringVelocity: 0.8, | |
| options: .curveEaseInOut, | |
| animations: { | |
| // Do animation | |
| }, completion: nil) |
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
| UIView.animate(withDuration: 2.0, animations: { () -> Void in | |
| circle.backgroundColor = UIColor.white | |
| appleImage.center = containerView.center | |
| }) |
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 circle = UIView( | |
| frame: CGRect(x: 0.0, y: 0.0, width: 64.0, height: 64.0) | |
| ) | |
| circle.center = containerView.center | |
| circle.backgroundColor = UIColor.blue | |
| circle.layer.borderColor = UIColor.blue.cgColor | |
| circle.layer.cornerRadius = 32.0 | |
| circle.layer.borderWidth = 2.0 | |
| containerView.addSubview(circle) |
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 appleImage = UIImageView( | |
| frame: CGRect(x: 160.0, y: 0.0, width: 50.0, height: 60.0) | |
| ) | |
| appleImage.image = UIImage(named: "apple") | |
| containerView.addSubview(appleImage) |
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 containerView = UIView( | |
| frame: CGRect(x: 0.0, y: 0.0, width: 375.0, height: 667.0) | |
| ) | |
| containerView.backgroundColor = UIColor.white |
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
| platform :ios, '9.0' | |
| use_frameworks! | |
| pod 'PureLayout' |
NewerOlder