diff --git a/Plum-o-Meter/AppDelegate.swift b/Plum-o-Meter/AppDelegate.swift index ae1e80b..d3d3731 100644 --- a/Plum-o-Meter/AppDelegate.swift +++ b/Plum-o-Meter/AppDelegate.swift @@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - func applicationDidBecomeActive(application: UIApplication) { + func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/Plum-o-Meter/Assets.xcassets/AppIcon.appiconset/Contents.json b/Plum-o-Meter/Assets.xcassets/AppIcon.appiconset/Contents.json index 36d2c80..d8db8d6 100644 --- a/Plum-o-Meter/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Plum-o-Meter/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", @@ -30,6 +40,16 @@ "size" : "60x60", "scale" : "3x" }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, { "idiom" : "ipad", "size" : "29x29", @@ -59,6 +79,16 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/Plum-o-Meter/Base.lproj/Main.storyboard b/Plum-o-Meter/Base.lproj/Main.storyboard index 3a2a49b..acc9cb2 100644 --- a/Plum-o-Meter/Base.lproj/Main.storyboard +++ b/Plum-o-Meter/Base.lproj/Main.storyboard @@ -1,21 +1,26 @@ - - + + + + + - + + + - + - + - + diff --git a/Plum-o-Meter/Info.plist b/Plum-o-Meter/Info.plist index 40c6215..44468d2 100644 --- a/Plum-o-Meter/Info.plist +++ b/Plum-o-Meter/Info.plist @@ -30,6 +30,8 @@ armv7 + UIStatusBarHidden + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/Plum-o-Meter/ViewController.swift b/Plum-o-Meter/ViewController.swift index 9e930c0..c94c90a 100644 --- a/Plum-o-Meter/ViewController.swift +++ b/Plum-o-Meter/ViewController.swift @@ -19,24 +19,24 @@ class ViewController: UIViewController { super.viewDidLoad() - view.multipleTouchEnabled = true + view.isMultipleTouchEnabled = true label.text = "lay your plums on me." - label.textAlignment = NSTextAlignment.Center + label.textAlignment = NSTextAlignment.center view.addSubview(label) } - override func touchesBegan(touches: Set, withEvent event: UIEvent?) + override func touchesBegan(_ touches: Set, with event: UIEvent?) { - label.hidden = true + label.isHidden = true for touch in touches { let circle = CircleWithLabel() - circle.drawAtPoint(touch.locationInView(view), + circle.drawAtPoint(location: touch.location(in: view), force: touch.force / touch.maximumPossibleForce) circles[touch] = circle @@ -46,33 +46,33 @@ class ViewController: UIViewController highlightHeaviest() } - override func touchesMoved(touches: Set, withEvent event: UIEvent?) + override func touchesMoved(_ touches: Set, with event: UIEvent?) { for touch in touches where circles[touch] != nil { let circle = circles[touch]! - circle.drawAtPoint(touch.locationInView(view), + circle.drawAtPoint(location: touch.location(in: view), force: touch.force / touch.maximumPossibleForce) } highlightHeaviest() } - override func touchesEnded(touches: Set, withEvent event: UIEvent?) + override func touchesEnded(_ touches: Set, with event: UIEvent?) { for touch in touches where circles[touch] != nil { let circle = circles[touch]! - circles.removeValueForKey(touch) + circles.removeValue(forKey: touch) circle.removeFromSuperlayer() } highlightHeaviest() } - override func touchesCancelled(touches: Set?, withEvent event: UIEvent?) + override func touchesCancelled(_ touches: Set?, with event: UIEvent?) { guard let touches = touches else { @@ -91,7 +91,7 @@ class ViewController: UIViewController { func getMaxTouch() -> UITouch? { - return circles.sort({ + return circles.sorted(by: { (a: (UITouch, CircleWithLabel), b: (UITouch, CircleWithLabel)) -> Bool in return a.0.force > b.0.force @@ -104,9 +104,8 @@ class ViewController: UIViewController } } - override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask - { - return UIInterfaceOrientationMask.Landscape + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + return .landscape } override func viewDidLayoutSubviews() @@ -125,16 +124,16 @@ class CircleWithLabel: CAShapeLayer { super.init() - text.foregroundColor = UIColor.blueColor().CGColor - text.alignmentMode = kCAAlignmentCenter + text.foregroundColor = UIColor.blue.cgColor + text.alignmentMode = CATextLayerAlignmentMode.center addSublayer(text) - strokeColor = UIColor.blueColor().CGColor + strokeColor = UIColor.blue.cgColor lineWidth = 5 fillColor = nil } - override init(layer: AnyObject) + override init(layer: Any) { super.init(layer: layer) } @@ -148,7 +147,7 @@ class CircleWithLabel: CAShapeLayer { didSet { - fillColor = isMax ? UIColor.yellowColor().CGColor : nil + fillColor = isMax ? UIColor.yellow.cgColor : nil } } @@ -157,9 +156,9 @@ class CircleWithLabel: CAShapeLayer let radius = 120 + (force * 120) path = UIBezierPath( - ovalInRect: CGRect( + ovalIn: CGRect( origin: location.offset(dx: radius, dy: radius), - size: CGSize(width: radius * 2, height: radius * 2))).CGPath + size: CGSize(width: radius * 2, height: radius * 2))).cgPath text.string = String(format: "%.1f%%", force * 100) @@ -171,7 +170,7 @@ class CircleWithLabel: CAShapeLayer extension CGPoint { - func offset(dx dx: CGFloat, dy: CGFloat) -> CGPoint + func offset(dx: CGFloat, dy: CGFloat) -> CGPoint { return CGPoint(x: self.x - dx, y: self.y - dy) }