Created
October 17, 2017 15:32
-
-
Save terrybu/00fed99a815cfb98e1ead432db1142f7 to your computer and use it in GitHub Desktop.
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
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
class MyViewController : UIViewController { | |
override func loadView() { | |
let view = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 375.0, height: 667.0)) | |
view.backgroundColor = .white | |
let circle = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0)) | |
circle.center = view.center | |
circle.layer.cornerRadius = 25.0 | |
let startingColor = UIColor(red: (0/255.0), green: (159.0/255.0), blue: (47.0/255.0), alpha: 1.0) | |
circle.backgroundColor = startingColor | |
view.addSubview(circle); | |
let rectangle = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0)) | |
rectangle.center = view.center | |
rectangle.layer.cornerRadius = 5.0 | |
rectangle.backgroundColor = UIColor.white | |
view.addSubview(rectangle) | |
UIView.animate(withDuration: 2.0, animations: { () -> Void in | |
let endingColor = UIColor(red: (255.0/255.0), green: (61.0/255.0), blue: (247.0/255.0), alpha: 0.5) | |
circle.backgroundColor = endingColor | |
let scaleTransform = CGAffineTransform(scaleX: 5.0, y: 5.0) | |
circle.transform = scaleTransform | |
let rotationTransform = CGAffineTransform(rotationAngle: 3.14) | |
rectangle.transform = rotationTransform | |
}) | |
self.view = view | |
} | |
} | |
// Present the view controller in the Live View window | |
PlaygroundPage.current.liveView = MyViewController() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment