├── Timer.gif
├── README.md
├── P2MSCountDownTimer.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
├── P2MSCountDownTimer
├── Classes
│ ├── Dictionary+P2MSAddition.swift
│ ├── UIColor+Interpolate.swift
│ ├── P2MSCountdownTimer.swift
│ └── UIView+P2MSAddition.swift
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── AppDelegate.swift
├── ViewController.swift
└── Base.lproj
│ ├── Main.storyboard
│ └── LaunchScreen.xib
├── .gitignore
├── P2MSCountDownTimerTests
├── Info.plist
└── P2MSCountDownTimerTests.swift
└── LICENSE
/Timer.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ptwoms/CountDownTimer/HEAD/Timer.gif
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CountDownTimer
2 |
3 | Just for fun with Swift!
4 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer/Classes/Dictionary+P2MSAddition.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Dictionary+P2MSAddition.swift
3 | // P2MSCircularBreadCrumbView
4 | //
5 | // Created by Pyae Phyo Myint Soe on 1/9/15.
6 | // Copyright (c) 2015 PYAE PHYO MYINT SOE. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import UIKit
11 |
12 | extension Dictionary{
13 | static func DictionaryOfVariableBindings(views: UIView...) -> Dictionary{
14 | var newDictionary = Dictionary();
15 | for (index,value) in views.enumerate(){
16 | newDictionary["v\(index+1)"] = value
17 | }
18 | return newDictionary
19 | }
20 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 | .DS_Store
20 |
21 | # CocoaPods
22 | #
23 | # We recommend against adding the Pods directory to your .gitignore. However
24 | # you should judge for yourself, the pros and cons are mentioned at:
25 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
26 | #
27 | # Pods/
28 |
29 | # Carthage
30 | #
31 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
32 | # Carthage/Checkouts
33 |
34 | Carthage/Build
35 |
--------------------------------------------------------------------------------
/P2MSCountDownTimerTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/P2MSCountDownTimerTests/P2MSCountDownTimerTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // P2MSCountDownTimerTests.swift
3 | // P2MSCountDownTimerTests
4 | //
5 | // Created by Pyae Phyo Myint Soe on 26/6/15.
6 | // Copyright (c) 2015 PYAE PHYO MYINT SOE. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import XCTest
11 |
12 | class P2MSCountDownTimerTests: XCTestCase {
13 |
14 | override func setUp() {
15 | super.setUp()
16 | // Put setup code here. This method is called before the invocation of each test method in the class.
17 | }
18 |
19 | override func tearDown() {
20 | // Put teardown code here. This method is called after the invocation of each test method in the class.
21 | super.tearDown()
22 | }
23 |
24 | func testExample() {
25 | // This is an example of a functional test case.
26 | XCTAssert(true, "Pass")
27 | }
28 |
29 | func testPerformanceExample() {
30 | // This is an example of a performance test case.
31 | self.measureBlock() {
32 | // Put the code you want to measure the time of here.
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Pyae Phyo Myint Soe
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer/Classes/UIColor+Interpolate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+Interpolate.swift
3 | // P2MSCountDownTimer
4 | //
5 | // Created by Pyae Phyo Myint Soe on 16/9/15.
6 | // Copyright © 2015 PYAE PHYO MYINT SOE. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | extension UIColor {
12 | class func interpolatedColorBetweenColor(firstColor: UIColor, andColor lastColor: UIColor, ratio aRatio: CGFloat) -> UIColor{
13 | let firstColorComponents = CGColorGetComponents(firstColor.CGColor)
14 | let secondColorComponents = CGColorGetComponents(lastColor.CGColor)
15 |
16 | let numberOfComp : Int = CGColorGetNumberOfComponents(firstColor.CGColor)
17 | var interpolatedComponents = [CGFloat](count: numberOfComp, repeatedValue: 0)
18 | for index in 0...numberOfComp-1{
19 | interpolatedComponents[index] = firstColorComponents[index] * (1 - aRatio) + secondColorComponents[index] * aRatio
20 | }
21 | let interpolatedCGColor = CGColorCreate(CGColorGetColorSpace(firstColor.CGColor), interpolatedComponents)
22 | if interpolatedCGColor != nil{
23 | //no need to call CGColorRelease in swift
24 | return UIColor(CGColor: interpolatedCGColor!)
25 | }
26 | return UIColor.clearColor()
27 | }
28 | }
--------------------------------------------------------------------------------
/P2MSCountDownTimer/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/P2MSCountDownTimer/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // P2MSCountDownTimer
4 | //
5 | // Created by Pyae Phyo Myint Soe on 26/6/15.
6 | // Copyright (c) 2015 PYAE PHYO MYINT SOE. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(application: UIApplication) {
23 | // 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.
24 | // 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.
25 | }
26 |
27 | func applicationDidEnterBackground(application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationDidBecomeActive(application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // P2MSCountDownTimer
4 | //
5 | // Created by Pyae Phyo Myint Soe on 26/6/15.
6 | // Copyright (c) 2015 PYAE PHYO MYINT SOE. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ViewController: UIViewController, P2MSCountdownTimerCallback {
12 | var associatedLabel : UILabel?
13 | var myTimer : P2MSCountdownTimer?
14 | @IBOutlet var startButton : UIButton?
15 | override func viewDidLoad() {
16 | super.viewDidLoad()
17 | myTimer = P2MSCountdownTimer.autoLayoutView()
18 | self.view.addSubview(myTimer!);
19 | self.view .addWidth(50, andHeight: 50, toView: myTimer!)
20 | self.view .addTopPadding(100, withSubView: myTimer!)
21 | self.view.centerHorizontalSubView(myTimer!)
22 | myTimer?.radius = 25;
23 | myTimer?.delegate = self
24 | myTimer?.lineWidth = 5;
25 | myTimer?.showCountDownLabel = true
26 | myTimer?.timerExpiredColor = UIColor.lightGrayColor()
27 |
28 | associatedLabel = UILabel.autoLayoutView()
29 | self.view.addSubview(associatedLabel!)
30 | self.view.addPadding(10, betweenTopView: myTimer!, andBottomView: associatedLabel!)
31 | self.view.centerHorizontalSubView(associatedLabel!)
32 | associatedLabel!.text = ""
33 | myTimer?.associatedColorChangeLabel = associatedLabel
34 | }
35 |
36 | @IBAction func restartClicked(sender : UIControl){
37 | myTimer?.startTime = NSDate()
38 | myTimer?.endTime = NSDate(timeInterval: 5, sinceDate: myTimer!.startTime!)
39 | myTimer?.startTimer()
40 | startButton?.enabled = false
41 | }
42 |
43 | override func didReceiveMemoryWarning() {
44 | super.didReceiveMemoryWarning()
45 | // Dispose of any resources that can be recreated.
46 | }
47 |
48 | func timerStarted(timer: P2MSCountdownTimer) {
49 | NSLog("Timer Started")
50 | }
51 |
52 | func timerExpired(timer: P2MSCountdownTimer) {
53 | NSLog("Timer Expired")
54 | associatedLabel!.text = "Timer has expired..."
55 | startButton?.enabled = true
56 | }
57 |
58 | func timerTickedInSeconds(curSecond: Int, timer aTimer: P2MSCountdownTimer) {
59 | if aTimer.isTimerStarted() && aTimer.isTimerExpired(){
60 | associatedLabel!.text = "This quote has expired..."
61 | }else{
62 | associatedLabel!.text = String(format: "Next %d seconds remaining...", curSecond)
63 | }
64 | }
65 |
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer/Classes/P2MSCountdownTimer.swift:
--------------------------------------------------------------------------------
1 | //
2 | // P2MSCountdownTimer.swift
3 | // P2MSCountDownTimer
4 | //
5 | // Created by Pyae Phyo Myint Soe on 26/6/15.
6 | // Copyright (c) 2015 PYAE PHYO MYINT SOE. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | let FIRE_INTERVAL:NSTimeInterval = 0.5
12 |
13 | protocol P2MSCountdownTimerCallback: class{
14 | func timerExpired(timer: P2MSCountdownTimer)
15 | func timerStarted(timer: P2MSCountdownTimer)
16 | func timerTickedInSeconds(curSecond : Int, timer aTimer: P2MSCountdownTimer)
17 | }
18 |
19 | enum COUNT_DOWN_TYPE {
20 | case COUNT_DOWN_TYPE_SECONDS, COUNT_DOWN_TYPE_MINUTES, COUNT_DOWN_TYPE_HOURS
21 | }
22 |
23 | class P2MSCountdownTimer: UIView {
24 |
25 | weak var delegate: P2MSCountdownTimerCallback?
26 | weak var associatedColorChangeLabel : UILabel?
27 |
28 | var radius, lineWidth: CGFloat;
29 | var isTimerActvie : Bool = false
30 | private var outerRadius :CGFloat{ get{ return radius; } };
31 | private var innerRadius :CGFloat{ get{ return radius-lineWidth; } };
32 | var startTime: NSDate? = nil, endTime : NSDate? = nil
33 | var strokeBackgroundColor: UIColor
34 | var timerExpiredColor: UIColor? = nil
35 | var completedPercentage: CGFloat = 0
36 | var elapsedTimeColors : Array = [ UIColor(red: 0.03921, green: 0.513725, blue: 0.23529, alpha: 1.0), UIColor(red: 0.03921, green: 0.513725, blue: 0.23529, alpha: 1.0), UIColor(red: 0.8, green: 0.6, blue: 0.0, alpha: 1.0), UIColor(red: 0.8, green: 0.0, blue: 0.0, alpha: 1.0)];
37 |
38 | private var timer : NSTimer? = nil
39 | private var startIntervals: NSTimeInterval = 0, endIntervals: NSTimeInterval = 0;
40 | private var innerPadding: CGFloat = 1;
41 | private var curCountdownTick : NSTimeInterval = -1
42 |
43 | var countDownType : COUNT_DOWN_TYPE = COUNT_DOWN_TYPE.COUNT_DOWN_TYPE_SECONDS
44 | var countdownLabel : UILabel?
45 | var showCountDownLabel : Bool{
46 | get{
47 | return countdownLabel != nil
48 | }
49 | set(showLabel){
50 | if showLabel{
51 | if countdownLabel == nil{
52 | countdownLabel = UILabel.autoLayoutView()
53 | countdownLabel!.textAlignment = NSTextAlignment.Center
54 | self.addSubview(countdownLabel!)
55 | self.matchSidesForView(self, withView: countdownLabel!)
56 | }
57 | }else{
58 | countdownLabel?.removeFromSuperview()
59 | countdownLabel = nil
60 | }
61 | }
62 | }
63 |
64 |
65 | override init(frame: CGRect) {
66 | self.radius = 10;
67 | self.lineWidth = 2;
68 | self.strokeBackgroundColor = UIColor(white: 0.8, alpha: 1.0)
69 | super.init(frame: frame)
70 | self.backgroundColor = UIColor.clearColor()
71 | }
72 |
73 | func DEGREES_TO_RADIANS(degree : CGFloat) -> CGFloat{
74 | return (CGFloat(M_PI) * degree)/180.0;
75 | }
76 |
77 | convenience init(){
78 | self.init(frame: CGRect.zero)
79 | }
80 |
81 | required init?(coder aDecoder: NSCoder) {
82 | radius = 10;
83 | lineWidth = 2;
84 | self.strokeBackgroundColor = UIColor(white: 0.8, alpha: 1.0)
85 | super.init(coder: aDecoder)
86 | }
87 |
88 | override func drawRect(rect: CGRect) {
89 | super.drawRect(rect);
90 | let center :CGPoint = CGPoint(x: bounds.size.width/2, y: bounds.size.height/2)
91 | let lineWidth : CGFloat = self.outerRadius - self.innerRadius;
92 | let calcRadius : CGFloat = self.innerRadius + lineWidth/2;
93 |
94 | let backgroundCircle: UIBezierPath = UIBezierPath(arcCenter: center, radius: calcRadius, startAngle: DEGREES_TO_RADIANS(0.0), endAngle: DEGREES_TO_RADIANS(360.0), clockwise: true);
95 | backgroundCircle.lineWidth = lineWidth;
96 | strokeBackgroundColor.setStroke()
97 | backgroundCircle.stroke()
98 |
99 | var startAngle : CGFloat = 0.0;
100 | var degrees = CGFloat(360.0);
101 | let mtimerExpired = isTimerExpired();
102 | if (!isTimerStarted()) {
103 | degrees = 0.0;
104 | self.completedPercentage = 0.0;
105 | updateTimerLabelWithInterval(0)
106 | }else if (!mtimerExpired){
107 | startAngle = 270.0;
108 | let curIntervals = NSDate().timeIntervalSince1970;
109 | self.completedPercentage = CGFloat(min((curIntervals-self.startIntervals)/(self.endIntervals-self.startIntervals),1.0));
110 | let newInterval = endIntervals - curIntervals
111 | if newInterval != curCountdownTick{
112 | curCountdownTick = newInterval
113 | let calInterval = Int(ceil(endIntervals-curIntervals))
114 | updateTimerLabelWithInterval(calInterval)
115 | delegate?.timerTickedInSeconds(calInterval, timer: self)
116 | }
117 | degrees = self.completedPercentage * CGFloat(360);
118 | degrees = (degrees < CGFloat(90)) ? CGFloat(270)+degrees : degrees-CGFloat(90);
119 | }else{
120 | self.completedPercentage = CGFloat(1.0);
121 | updateTimerLabelWithInterval(0)
122 | }
123 |
124 | let elapsedTimePath = UIBezierPath(arcCenter: center, radius: calcRadius, startAngle: DEGREES_TO_RADIANS(startAngle), endAngle: DEGREES_TO_RADIANS(degrees), clockwise: true)
125 | var fillColor : UIColor?
126 | if isTimerExpired(){
127 | if isTimerActvie{
128 | isTimerActvie = false
129 | delegate?.timerExpired(self)
130 | }
131 | if timerExpiredColor != nil{
132 | fillColor = timerExpiredColor
133 | }else{
134 | fillColor = elapsedTimeColors.last
135 | }
136 | }else{
137 | let maxColorsIndex = elapsedTimeColors.count-1
138 | let individualColorSegment : CGFloat = CGFloat(1.0)/CGFloat(maxColorsIndex)
139 | let currentBetColorIndex = self.completedPercentage/individualColorSegment
140 |
141 | let baseColorIndex : Int = min(Int(floor(currentBetColorIndex)), maxColorsIndex-1)
142 | let nextColorIndex : Int = min(baseColorIndex+1, maxColorsIndex)
143 |
144 | let localisedMax : CGFloat = CGFloat(nextColorIndex) * individualColorSegment
145 | let localisedMin : CGFloat = CGFloat(baseColorIndex) * individualColorSegment
146 | let localisedPercentage :CGFloat = (self.completedPercentage-localisedMin)/(localisedMax-localisedMin)
147 | fillColor = UIColor.interpolatedColorBetweenColor(elapsedTimeColors[baseColorIndex], andColor: elapsedTimeColors[nextColorIndex], ratio: localisedPercentage)
148 | }
149 | fillColor!.setStroke()
150 | elapsedTimePath.lineWidth = lineWidth
151 | elapsedTimePath.stroke()
152 |
153 | let ctx = UIGraphicsGetCurrentContext()
154 | var backColor : UIColor
155 | if startAngle == degrees{
156 | backColor = strokeBackgroundColor
157 | }else{
158 | backColor = fillColor!
159 | associatedColorChangeLabel?.textColor = fillColor
160 | }
161 | let colors = CGColorGetComponents(backColor.CGColor)
162 | let backColorNoOfComponents = CGColorGetNumberOfComponents(backColor.CGColor)
163 | let modifiedAlphaComponent : CGFloat = 0.5
164 | if backColorNoOfComponents == 2{
165 | CGContextSetRGBFillColor(ctx, colors[0], colors[0], colors[0], modifiedAlphaComponent)
166 | }else if backColorNoOfComponents == 4{
167 | CGContextSetRGBFillColor(ctx, colors[0], colors[1], colors[2], modifiedAlphaComponent)
168 | }else{
169 | CGContextSetRGBFillColor(ctx, colors[0], colors[1], colors[2], modifiedAlphaComponent)
170 | }
171 | CGContextFillEllipseInRect(ctx, CGRect(x: center.x-self.innerRadius+self.innerPadding, y: center.y-self.innerRadius+self.innerPadding, width: (self.innerRadius-self.innerPadding)*2, height: (self.innerRadius-self.innerPadding)*2))
172 | CGContextFillPath(ctx)
173 |
174 | }
175 |
176 | deinit{
177 | clearTimer()
178 | }
179 |
180 | func clearTimer(){
181 | if((timer?.valid) != nil){
182 | timer?.invalidate()
183 | delegate?.timerExpired(self)
184 | }
185 | timer = nil;
186 | }
187 |
188 | func startTimer(){
189 | clearTimer()
190 | endIntervals = endTime!.timeIntervalSince1970
191 | startIntervals = startTime!.timeIntervalSince1970
192 | isTimerActvie = true
193 | if(startTime?.compare(NSDate()) == NSComparisonResult.OrderedDescending){
194 | timer = NSTimer.init(fireDate: startTime!, interval:FIRE_INTERVAL, target: self, selector: Selector ("updateTimerLayout"), userInfo: nil, repeats: true);
195 | }else{
196 | timer = NSTimer.scheduledTimerWithTimeInterval(FIRE_INTERVAL, target: self, selector: Selector("updateTimerLayout"), userInfo: nil, repeats: true);
197 | }
198 | delegate?.timerStarted(self)
199 | }
200 |
201 | func updateTimerLabelWithInterval(curInterval : Int){
202 | if countdownLabel != nil && startIntervals != endIntervals{
203 | countdownLabel?.text = String(curInterval)//
204 | }
205 | }
206 |
207 | func isTimerStarted() -> Bool{
208 | if startTime != nil{
209 | return (NSDate().compare(startTime!) != NSComparisonResult.OrderedAscending);
210 | }
211 | return false
212 | }
213 |
214 | func isTimerExpired() -> Bool{
215 | if endTime != nil{
216 | return (NSDate().compare(endTime!) != NSComparisonResult.OrderedAscending);
217 | }
218 | return true
219 | }
220 |
221 | func updateTimerLayout(){
222 | let isExpired : Bool = isTimerExpired()
223 | if(!isExpired){
224 | setNeedsDisplay();
225 | }else{
226 | timer?.invalidate();
227 | timer = nil;
228 | setNeedsDisplay()
229 | }
230 | }
231 | }
232 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer/Classes/UIView+P2MSAddition.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+P2MSAddition.swift
3 | // P2MSCircularBreadCrumbView
4 | //
5 | // Created by Pyae Phyo Myint Soe on 1/9/15.
6 | // Copyright (c) 2015 PYAE PHYO MYINT SOE. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | extension UIView{
12 | class func autoLayoutView() -> Self{
13 | let newView = self.init()
14 | newView.translatesAutoresizingMaskIntoConstraints = false
15 | return newView
16 | }
17 |
18 | func removeAllSubViews(){
19 | for subView in self.subviews{
20 | subView.removeFromSuperview()
21 | }
22 | }
23 |
24 | func createBotoomPadding(value: CGFloat, withSubView subView: UIView, andRelation relation: NSLayoutRelation) -> NSLayoutConstraint{
25 | return NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.Bottom, relatedBy: relation, toItem: subView, attribute: NSLayoutAttribute.Bottom, multiplier: 1.0, constant: value)
26 | }
27 |
28 | func addBottomPadding(value: CGFloat, withSubView subView: UIView, andPriority priority: UILayoutPriority = 1000) -> NSLayoutConstraint {
29 | let constraint = self .createBotoomPadding(value, withSubView: subView, andRelation: NSLayoutRelation.Equal);
30 | constraint.priority = priority
31 | self.addConstraint(constraint)
32 | return constraint
33 | }
34 |
35 | func getRelationString(relation : NSLayoutRelation) -> NSString{
36 | switch(relation){
37 | case NSLayoutRelation.GreaterThanOrEqual: return ">=";
38 | case NSLayoutRelation.LessThanOrEqual: return "<=";
39 | default: return ""
40 | }
41 | }
42 |
43 | func createLeftPadding(leftPadding: CGFloat, withSubView subView: UIView, relationship relation: NSLayoutRelation) -> NSLayoutConstraint{
44 | let view = Dictionary.DictionaryOfVariableBindings(subView)
45 | let allConstraints = NSLayoutConstraint.constraintsWithVisualFormat("|-(leftspace)-[v1]", options: NSLayoutFormatOptions.AlignAllLeft, metrics: ["leftspace": String(format: "%@%f", self.getRelationString(relation), leftPadding)], views: view)
46 | return allConstraints[0]
47 | }
48 |
49 | func addLeftPadding(leftPadding: CGFloat, withSubView subView: UIView, andPriority priority: UILayoutPriority = 1000) -> NSLayoutConstraint{
50 | let leftConstraint = self.createLeftPadding(leftPadding, withSubView: subView, relationship: NSLayoutRelation.Equal)
51 | leftConstraint.priority = priority
52 | self.addConstraint(leftConstraint)
53 | return leftConstraint
54 | }
55 |
56 | func createTopPadding(topPadding: CGFloat, withSubView subView: UIView, relationship relation: NSLayoutRelation) -> NSLayoutConstraint{
57 | let view = Dictionary.DictionaryOfVariableBindings(subView)
58 | let allConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|-(topspace)-[v1]", options: NSLayoutFormatOptions.AlignAllTop, metrics: ["topspace": String(format: "%@%f", self.getRelationString(relation), topPadding)], views: view)
59 | return allConstraints[0]
60 | }
61 |
62 | func addTopPadding(topPadding: CGFloat, withSubView subView: UIView, andPriority priority: UILayoutPriority = 1000) -> NSLayoutConstraint{
63 | let topConstraint = createTopPadding(topPadding, withSubView: subView, relationship: NSLayoutRelation.Equal)
64 | topConstraint.priority = priority
65 | self.addConstraint(topConstraint)
66 | return topConstraint
67 | }
68 |
69 | func addPadding(topPadding: CGFloat, betweenTopView topView: UIView, andBottomView bottomView: UIView, andPriority priority: UILayoutPriority = 1000) -> NSLayoutConstraint{
70 | let topConstraint = NSLayoutConstraint(item: bottomView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: topView, attribute: NSLayoutAttribute.Bottom, multiplier: 1.0, constant: topPadding)
71 | topConstraint.priority = priority
72 | self.addConstraint(topConstraint)
73 | return topConstraint
74 | }
75 |
76 | func addPadding(padding: CGFloat, betweenLeftView leftView: UIView, andRightView rightView: UIView, andPriority priority: UILayoutPriority = 1000) -> NSLayoutConstraint{
77 | let leftConstraint = NSLayoutConstraint(item: rightView, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: leftView, attribute: NSLayoutAttribute.Right, multiplier: 1.0, constant: padding)
78 | leftConstraint.priority = priority
79 | self.addConstraint(leftConstraint)
80 | return leftConstraint
81 | }
82 |
83 | func addLeftPadding(leftPadding: CGFloat, rightPadding aRightPadding: CGFloat, withSubView subView: UIView, andPriority priority: UILayoutPriority = 1000) -> Array{
84 | let view = Dictionary.DictionaryOfVariableBindings(subView);
85 | let constraints : Array = NSLayoutConstraint.constraintsWithVisualFormat("|-(leftspace)-[v1]-(rightspace)-|", options: NSLayoutFormatOptions.DirectionLeftToRight, metrics: ["leftspace":NSNumber(double: Double(leftPadding)), "rightspace":NSNumber(double: Double(aRightPadding))], views: view)
86 | for curConstraint in constraints{
87 | curConstraint.priority = priority
88 | }
89 | self.addConstraints(constraints)
90 | return constraints
91 | }
92 |
93 |
94 | func createRightPadding(rightPadding: CGFloat, withSubView subView: UIView, relationship relation: NSLayoutRelation) -> NSLayoutConstraint{
95 | let view = Dictionary.DictionaryOfVariableBindings(subView)
96 | let allConstraints = NSLayoutConstraint.constraintsWithVisualFormat("[v1]-(rightspace)-|", options: NSLayoutFormatOptions.AlignAllTop, metrics: ["rightspace": String(format: "%@%f", self.getRelationString(relation), rightPadding)], views: view)
97 | return allConstraints[0]
98 | }
99 |
100 | func addRightPadding(rightPadding: CGFloat, withSubView subView: UIView, andPriority priority: UILayoutPriority = 1000) -> NSLayoutConstraint{
101 | let rightConstraint = createRightPadding(rightPadding, withSubView: subView, relationship: NSLayoutRelation.Equal)
102 | rightConstraint.priority = priority
103 | self.addConstraint(rightConstraint)
104 | return rightConstraint
105 | }
106 |
107 | func addLeftPadding(leftPadding : CGFloat, rightPadding aRightPadding: CGFloat, topPadding aTopPadding: CGFloat, withSubView subView: UIView, andPriority priority: UILayoutPriority = 1000) -> Array{
108 | let views = Dictionary.DictionaryOfVariableBindings(subView)
109 | let metrics = [ "leftspace":NSNumber(double: Double(leftPadding)), "rightspace":NSNumber(double: Double(aRightPadding))]
110 | let lrConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|-(leftspace)-[v1]-(rightspace)-|", options:[NSLayoutFormatOptions.AlignAllLeading, NSLayoutFormatOptions.AlignAllTrailing], metrics: metrics, views: views)
111 | for curConstraint in lrConstraints{
112 | curConstraint.priority = priority
113 | }
114 | self.addConstraints(lrConstraints)
115 | let topConstraint = createTopPadding(aTopPadding, withSubView: subView, relationship: NSLayoutRelation.Equal)
116 | topConstraint.priority = priority;
117 | self.addConstraint(topConstraint)
118 | return [ (lrConstraints[0] ), (lrConstraints[1] ), topConstraint ]
119 | }
120 |
121 | // MARK: - Aligning two views
122 | func matchSidesForView(view1: UIView, withView view2: UIView){
123 | let leftConstraint = NSLayoutConstraint(item: view1, attribute: NSLayoutAttribute.Leading, relatedBy: NSLayoutRelation.Equal, toItem: view2, attribute: NSLayoutAttribute.Leading, multiplier: 1.0, constant: 0.0)
124 | let rightConstraint = NSLayoutConstraint(item: view1, attribute: NSLayoutAttribute.Trailing, relatedBy: NSLayoutRelation.Equal, toItem: view2, attribute: NSLayoutAttribute.Trailing, multiplier: 1.0, constant: 0.0)
125 | let topConstraint = NSLayoutConstraint(item: view1, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: view2, attribute: NSLayoutAttribute.Top, multiplier: 1.0, constant: 0.0)
126 | let bottomConstraint = NSLayoutConstraint(item: view1, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: view2, attribute: NSLayoutAttribute.Bottom, multiplier: 1.0, constant: 0.0)
127 | self.addConstraints([leftConstraint, rightConstraint, topConstraint, bottomConstraint])
128 | }
129 |
130 | // MARK: - Centering
131 | func createCenterVerticalSubView(subView: UIView, constant aConstant: CGFloat, relationship relation: NSLayoutRelation) -> NSLayoutConstraint{
132 | return NSLayoutConstraint(item: subView, attribute: NSLayoutAttribute.CenterY, relatedBy: relation, toItem: self, attribute: NSLayoutAttribute.CenterY, multiplier: 1.0, constant: aConstant)
133 | }
134 |
135 | func centerVerticalSubView(subView: UIView, constant aConstant: CGFloat) -> NSLayoutConstraint{
136 | let constraint = createCenterVerticalSubView(subView, constant: aConstant, relationship: NSLayoutRelation.Equal)
137 | self.addConstraint(constraint)
138 | return constraint;
139 | }
140 |
141 | func centerVerticalSubView(subView: UIView) -> NSLayoutConstraint{
142 | return centerVerticalSubView(subView, constant: 0);
143 | }
144 |
145 | func createCenterHorizontalSubView(subView: UIView, constant aConstant: CGFloat, relationship relation: NSLayoutRelation) -> NSLayoutConstraint{
146 | return NSLayoutConstraint(item: subView, attribute: NSLayoutAttribute.CenterX, relatedBy: relation, toItem: self, attribute: NSLayoutAttribute.CenterX, multiplier: 1.0, constant: aConstant)
147 | }
148 |
149 | func centerHorizontalSubView(subView : UIView) -> NSLayoutConstraint{
150 | let constraint = createCenterHorizontalSubView(subView, constant: 0, relationship: NSLayoutRelation.Equal);
151 | self.addConstraint(constraint)
152 | return constraint
153 | }
154 |
155 | // MARK: - Width & Height
156 | func createHeight(height: CGFloat, toView view: UIView, relationship relation: NSLayoutRelation) -> NSLayoutConstraint{
157 | return NSLayoutConstraint(item: view, attribute: NSLayoutAttribute.Height, relatedBy: relation, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: height)
158 | }
159 |
160 | func createWidth(width: CGFloat, toView view: UIView, relationship relation: NSLayoutRelation) -> NSLayoutConstraint{
161 | return NSLayoutConstraint(item: view, attribute: NSLayoutAttribute.Width, relatedBy: relation, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: width)
162 | }
163 |
164 | func addHeight(height: CGFloat, toView view: UIView, andPriority priority: UILayoutPriority = 1000) -> NSLayoutConstraint{
165 | let heightConstraint = createHeight(height, toView: view, relationship: NSLayoutRelation.Equal)
166 | heightConstraint.priority = priority
167 | self.addConstraint(heightConstraint)
168 | return heightConstraint
169 | }
170 |
171 | func addWidth(width: CGFloat, toView view: UIView, andPriority priority: UILayoutPriority = 1000) -> NSLayoutConstraint{
172 | let widthConstraint = createWidth(width, toView: view, relationship: NSLayoutRelation.Equal)
173 | widthConstraint.priority = priority
174 | self.addConstraint(widthConstraint)
175 | return widthConstraint
176 | }
177 |
178 | func addWidth(width: CGFloat, andHeight height: CGFloat, toView view: UIView, andPriority priority: UILayoutPriority = 1000) -> Array{
179 | let widthConstraint = self.addWidth(width, toView: view, andPriority: priority)
180 | let heightConstraint = self.addHeight(height, toView: view, andPriority: priority)
181 | return [widthConstraint, heightConstraint]
182 | }
183 |
184 | }
185 |
186 |
--------------------------------------------------------------------------------
/P2MSCountDownTimer.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 9936E6A11BAA6D99009BDAB6 /* UIView+P2MSAddition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9936E6A01BAA6D99009BDAB6 /* UIView+P2MSAddition.swift */; settings = {ASSET_TAGS = (); }; };
11 | 9936E6A31BAA6DEC009BDAB6 /* Dictionary+P2MSAddition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9936E6A21BAA6DEC009BDAB6 /* Dictionary+P2MSAddition.swift */; settings = {ASSET_TAGS = (); }; };
12 | 99441B9A1B3D040500DC40D8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99441B991B3D040500DC40D8 /* AppDelegate.swift */; };
13 | 99441B9C1B3D040500DC40D8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99441B9B1B3D040500DC40D8 /* ViewController.swift */; };
14 | 99441B9F1B3D040500DC40D8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 99441B9D1B3D040500DC40D8 /* Main.storyboard */; };
15 | 99441BA11B3D040500DC40D8 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 99441BA01B3D040500DC40D8 /* Images.xcassets */; };
16 | 99441BA41B3D040500DC40D8 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 99441BA21B3D040500DC40D8 /* LaunchScreen.xib */; };
17 | 99441BB01B3D040500DC40D8 /* P2MSCountDownTimerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99441BAF1B3D040500DC40D8 /* P2MSCountDownTimerTests.swift */; };
18 | 99441BC11B3D050500DC40D8 /* P2MSCountdownTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99441BC01B3D050500DC40D8 /* P2MSCountdownTimer.swift */; };
19 | 997504001BA95D000005ABE0 /* UIColor+Interpolate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 997503FF1BA95D000005ABE0 /* UIColor+Interpolate.swift */; settings = {ASSET_TAGS = (); }; };
20 | /* End PBXBuildFile section */
21 |
22 | /* Begin PBXContainerItemProxy section */
23 | 99441BAA1B3D040500DC40D8 /* PBXContainerItemProxy */ = {
24 | isa = PBXContainerItemProxy;
25 | containerPortal = 99441B8C1B3D040500DC40D8 /* Project object */;
26 | proxyType = 1;
27 | remoteGlobalIDString = 99441B931B3D040500DC40D8;
28 | remoteInfo = P2MSCountDownTimer;
29 | };
30 | /* End PBXContainerItemProxy section */
31 |
32 | /* Begin PBXFileReference section */
33 | 9936E6A01BAA6D99009BDAB6 /* UIView+P2MSAddition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+P2MSAddition.swift"; sourceTree = ""; };
34 | 9936E6A21BAA6DEC009BDAB6 /* Dictionary+P2MSAddition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Dictionary+P2MSAddition.swift"; sourceTree = ""; };
35 | 99441B941B3D040500DC40D8 /* P2MSCountDownTimer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = P2MSCountDownTimer.app; sourceTree = BUILT_PRODUCTS_DIR; };
36 | 99441B981B3D040500DC40D8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
37 | 99441B991B3D040500DC40D8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
38 | 99441B9B1B3D040500DC40D8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
39 | 99441B9E1B3D040500DC40D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
40 | 99441BA01B3D040500DC40D8 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
41 | 99441BA31B3D040500DC40D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
42 | 99441BA91B3D040500DC40D8 /* P2MSCountDownTimerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = P2MSCountDownTimerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
43 | 99441BAE1B3D040500DC40D8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
44 | 99441BAF1B3D040500DC40D8 /* P2MSCountDownTimerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = P2MSCountDownTimerTests.swift; sourceTree = ""; };
45 | 99441BC01B3D050500DC40D8 /* P2MSCountdownTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = P2MSCountdownTimer.swift; sourceTree = ""; };
46 | 997503FF1BA95D000005ABE0 /* UIColor+Interpolate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+Interpolate.swift"; sourceTree = ""; };
47 | /* End PBXFileReference section */
48 |
49 | /* Begin PBXFrameworksBuildPhase section */
50 | 99441B911B3D040500DC40D8 /* Frameworks */ = {
51 | isa = PBXFrameworksBuildPhase;
52 | buildActionMask = 2147483647;
53 | files = (
54 | );
55 | runOnlyForDeploymentPostprocessing = 0;
56 | };
57 | 99441BA61B3D040500DC40D8 /* Frameworks */ = {
58 | isa = PBXFrameworksBuildPhase;
59 | buildActionMask = 2147483647;
60 | files = (
61 | );
62 | runOnlyForDeploymentPostprocessing = 0;
63 | };
64 | /* End PBXFrameworksBuildPhase section */
65 |
66 | /* Begin PBXGroup section */
67 | 99441B8B1B3D040500DC40D8 = {
68 | isa = PBXGroup;
69 | children = (
70 | 99441B961B3D040500DC40D8 /* P2MSCountDownTimer */,
71 | 99441BAC1B3D040500DC40D8 /* P2MSCountDownTimerTests */,
72 | 99441B951B3D040500DC40D8 /* Products */,
73 | );
74 | sourceTree = "";
75 | };
76 | 99441B951B3D040500DC40D8 /* Products */ = {
77 | isa = PBXGroup;
78 | children = (
79 | 99441B941B3D040500DC40D8 /* P2MSCountDownTimer.app */,
80 | 99441BA91B3D040500DC40D8 /* P2MSCountDownTimerTests.xctest */,
81 | );
82 | name = Products;
83 | sourceTree = "";
84 | };
85 | 99441B961B3D040500DC40D8 /* P2MSCountDownTimer */ = {
86 | isa = PBXGroup;
87 | children = (
88 | 99441BBB1B3D044700DC40D8 /* Classes */,
89 | 99441B991B3D040500DC40D8 /* AppDelegate.swift */,
90 | 99441B9B1B3D040500DC40D8 /* ViewController.swift */,
91 | 99441B9D1B3D040500DC40D8 /* Main.storyboard */,
92 | 99441BA01B3D040500DC40D8 /* Images.xcassets */,
93 | 99441BA21B3D040500DC40D8 /* LaunchScreen.xib */,
94 | 99441B971B3D040500DC40D8 /* Supporting Files */,
95 | );
96 | path = P2MSCountDownTimer;
97 | sourceTree = "";
98 | };
99 | 99441B971B3D040500DC40D8 /* Supporting Files */ = {
100 | isa = PBXGroup;
101 | children = (
102 | 99441B981B3D040500DC40D8 /* Info.plist */,
103 | );
104 | name = "Supporting Files";
105 | sourceTree = "";
106 | };
107 | 99441BAC1B3D040500DC40D8 /* P2MSCountDownTimerTests */ = {
108 | isa = PBXGroup;
109 | children = (
110 | 99441BAF1B3D040500DC40D8 /* P2MSCountDownTimerTests.swift */,
111 | 99441BAD1B3D040500DC40D8 /* Supporting Files */,
112 | );
113 | path = P2MSCountDownTimerTests;
114 | sourceTree = "";
115 | };
116 | 99441BAD1B3D040500DC40D8 /* Supporting Files */ = {
117 | isa = PBXGroup;
118 | children = (
119 | 99441BAE1B3D040500DC40D8 /* Info.plist */,
120 | );
121 | name = "Supporting Files";
122 | sourceTree = "";
123 | };
124 | 99441BBB1B3D044700DC40D8 /* Classes */ = {
125 | isa = PBXGroup;
126 | children = (
127 | 9936E6A21BAA6DEC009BDAB6 /* Dictionary+P2MSAddition.swift */,
128 | 9936E6A01BAA6D99009BDAB6 /* UIView+P2MSAddition.swift */,
129 | 99441BC01B3D050500DC40D8 /* P2MSCountdownTimer.swift */,
130 | 997503FF1BA95D000005ABE0 /* UIColor+Interpolate.swift */,
131 | );
132 | path = Classes;
133 | sourceTree = "";
134 | };
135 | /* End PBXGroup section */
136 |
137 | /* Begin PBXNativeTarget section */
138 | 99441B931B3D040500DC40D8 /* P2MSCountDownTimer */ = {
139 | isa = PBXNativeTarget;
140 | buildConfigurationList = 99441BB31B3D040500DC40D8 /* Build configuration list for PBXNativeTarget "P2MSCountDownTimer" */;
141 | buildPhases = (
142 | 99441B901B3D040500DC40D8 /* Sources */,
143 | 99441B911B3D040500DC40D8 /* Frameworks */,
144 | 99441B921B3D040500DC40D8 /* Resources */,
145 | );
146 | buildRules = (
147 | );
148 | dependencies = (
149 | );
150 | name = P2MSCountDownTimer;
151 | productName = P2MSCountDownTimer;
152 | productReference = 99441B941B3D040500DC40D8 /* P2MSCountDownTimer.app */;
153 | productType = "com.apple.product-type.application";
154 | };
155 | 99441BA81B3D040500DC40D8 /* P2MSCountDownTimerTests */ = {
156 | isa = PBXNativeTarget;
157 | buildConfigurationList = 99441BB61B3D040500DC40D8 /* Build configuration list for PBXNativeTarget "P2MSCountDownTimerTests" */;
158 | buildPhases = (
159 | 99441BA51B3D040500DC40D8 /* Sources */,
160 | 99441BA61B3D040500DC40D8 /* Frameworks */,
161 | 99441BA71B3D040500DC40D8 /* Resources */,
162 | );
163 | buildRules = (
164 | );
165 | dependencies = (
166 | 99441BAB1B3D040500DC40D8 /* PBXTargetDependency */,
167 | );
168 | name = P2MSCountDownTimerTests;
169 | productName = P2MSCountDownTimerTests;
170 | productReference = 99441BA91B3D040500DC40D8 /* P2MSCountDownTimerTests.xctest */;
171 | productType = "com.apple.product-type.bundle.unit-test";
172 | };
173 | /* End PBXNativeTarget section */
174 |
175 | /* Begin PBXProject section */
176 | 99441B8C1B3D040500DC40D8 /* Project object */ = {
177 | isa = PBXProject;
178 | attributes = {
179 | LastSwiftMigration = 0700;
180 | LastSwiftUpdateCheck = 0700;
181 | LastUpgradeCheck = 0700;
182 | ORGANIZATIONNAME = "PYAE PHYO MYINT SOE";
183 | TargetAttributes = {
184 | 99441B931B3D040500DC40D8 = {
185 | CreatedOnToolsVersion = 6.3.2;
186 | };
187 | 99441BA81B3D040500DC40D8 = {
188 | CreatedOnToolsVersion = 6.3.2;
189 | TestTargetID = 99441B931B3D040500DC40D8;
190 | };
191 | };
192 | };
193 | buildConfigurationList = 99441B8F1B3D040500DC40D8 /* Build configuration list for PBXProject "P2MSCountDownTimer" */;
194 | compatibilityVersion = "Xcode 3.2";
195 | developmentRegion = English;
196 | hasScannedForEncodings = 0;
197 | knownRegions = (
198 | en,
199 | Base,
200 | );
201 | mainGroup = 99441B8B1B3D040500DC40D8;
202 | productRefGroup = 99441B951B3D040500DC40D8 /* Products */;
203 | projectDirPath = "";
204 | projectRoot = "";
205 | targets = (
206 | 99441B931B3D040500DC40D8 /* P2MSCountDownTimer */,
207 | 99441BA81B3D040500DC40D8 /* P2MSCountDownTimerTests */,
208 | );
209 | };
210 | /* End PBXProject section */
211 |
212 | /* Begin PBXResourcesBuildPhase section */
213 | 99441B921B3D040500DC40D8 /* Resources */ = {
214 | isa = PBXResourcesBuildPhase;
215 | buildActionMask = 2147483647;
216 | files = (
217 | 99441B9F1B3D040500DC40D8 /* Main.storyboard in Resources */,
218 | 99441BA41B3D040500DC40D8 /* LaunchScreen.xib in Resources */,
219 | 99441BA11B3D040500DC40D8 /* Images.xcassets in Resources */,
220 | );
221 | runOnlyForDeploymentPostprocessing = 0;
222 | };
223 | 99441BA71B3D040500DC40D8 /* Resources */ = {
224 | isa = PBXResourcesBuildPhase;
225 | buildActionMask = 2147483647;
226 | files = (
227 | );
228 | runOnlyForDeploymentPostprocessing = 0;
229 | };
230 | /* End PBXResourcesBuildPhase section */
231 |
232 | /* Begin PBXSourcesBuildPhase section */
233 | 99441B901B3D040500DC40D8 /* Sources */ = {
234 | isa = PBXSourcesBuildPhase;
235 | buildActionMask = 2147483647;
236 | files = (
237 | 99441BC11B3D050500DC40D8 /* P2MSCountdownTimer.swift in Sources */,
238 | 9936E6A31BAA6DEC009BDAB6 /* Dictionary+P2MSAddition.swift in Sources */,
239 | 99441B9C1B3D040500DC40D8 /* ViewController.swift in Sources */,
240 | 9936E6A11BAA6D99009BDAB6 /* UIView+P2MSAddition.swift in Sources */,
241 | 99441B9A1B3D040500DC40D8 /* AppDelegate.swift in Sources */,
242 | 997504001BA95D000005ABE0 /* UIColor+Interpolate.swift in Sources */,
243 | );
244 | runOnlyForDeploymentPostprocessing = 0;
245 | };
246 | 99441BA51B3D040500DC40D8 /* Sources */ = {
247 | isa = PBXSourcesBuildPhase;
248 | buildActionMask = 2147483647;
249 | files = (
250 | 99441BB01B3D040500DC40D8 /* P2MSCountDownTimerTests.swift in Sources */,
251 | );
252 | runOnlyForDeploymentPostprocessing = 0;
253 | };
254 | /* End PBXSourcesBuildPhase section */
255 |
256 | /* Begin PBXTargetDependency section */
257 | 99441BAB1B3D040500DC40D8 /* PBXTargetDependency */ = {
258 | isa = PBXTargetDependency;
259 | target = 99441B931B3D040500DC40D8 /* P2MSCountDownTimer */;
260 | targetProxy = 99441BAA1B3D040500DC40D8 /* PBXContainerItemProxy */;
261 | };
262 | /* End PBXTargetDependency section */
263 |
264 | /* Begin PBXVariantGroup section */
265 | 99441B9D1B3D040500DC40D8 /* Main.storyboard */ = {
266 | isa = PBXVariantGroup;
267 | children = (
268 | 99441B9E1B3D040500DC40D8 /* Base */,
269 | );
270 | name = Main.storyboard;
271 | sourceTree = "";
272 | };
273 | 99441BA21B3D040500DC40D8 /* LaunchScreen.xib */ = {
274 | isa = PBXVariantGroup;
275 | children = (
276 | 99441BA31B3D040500DC40D8 /* Base */,
277 | );
278 | name = LaunchScreen.xib;
279 | sourceTree = "";
280 | };
281 | /* End PBXVariantGroup section */
282 |
283 | /* Begin XCBuildConfiguration section */
284 | 99441BB11B3D040500DC40D8 /* Debug */ = {
285 | isa = XCBuildConfiguration;
286 | buildSettings = {
287 | ALWAYS_SEARCH_USER_PATHS = NO;
288 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
289 | CLANG_CXX_LIBRARY = "libc++";
290 | CLANG_ENABLE_MODULES = YES;
291 | CLANG_ENABLE_OBJC_ARC = YES;
292 | CLANG_WARN_BOOL_CONVERSION = YES;
293 | CLANG_WARN_CONSTANT_CONVERSION = YES;
294 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
295 | CLANG_WARN_EMPTY_BODY = YES;
296 | CLANG_WARN_ENUM_CONVERSION = YES;
297 | CLANG_WARN_INT_CONVERSION = YES;
298 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
299 | CLANG_WARN_UNREACHABLE_CODE = YES;
300 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
301 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
302 | COPY_PHASE_STRIP = NO;
303 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
304 | ENABLE_STRICT_OBJC_MSGSEND = YES;
305 | ENABLE_TESTABILITY = YES;
306 | GCC_C_LANGUAGE_STANDARD = gnu99;
307 | GCC_DYNAMIC_NO_PIC = NO;
308 | GCC_NO_COMMON_BLOCKS = YES;
309 | GCC_OPTIMIZATION_LEVEL = 0;
310 | GCC_PREPROCESSOR_DEFINITIONS = (
311 | "DEBUG=1",
312 | "$(inherited)",
313 | );
314 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
315 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
316 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
317 | GCC_WARN_UNDECLARED_SELECTOR = YES;
318 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
319 | GCC_WARN_UNUSED_FUNCTION = YES;
320 | GCC_WARN_UNUSED_VARIABLE = YES;
321 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
322 | MTL_ENABLE_DEBUG_INFO = YES;
323 | ONLY_ACTIVE_ARCH = YES;
324 | SDKROOT = iphoneos;
325 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
326 | TARGETED_DEVICE_FAMILY = "1,2";
327 | };
328 | name = Debug;
329 | };
330 | 99441BB21B3D040500DC40D8 /* Release */ = {
331 | isa = XCBuildConfiguration;
332 | buildSettings = {
333 | ALWAYS_SEARCH_USER_PATHS = NO;
334 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
335 | CLANG_CXX_LIBRARY = "libc++";
336 | CLANG_ENABLE_MODULES = YES;
337 | CLANG_ENABLE_OBJC_ARC = YES;
338 | CLANG_WARN_BOOL_CONVERSION = YES;
339 | CLANG_WARN_CONSTANT_CONVERSION = YES;
340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
341 | CLANG_WARN_EMPTY_BODY = YES;
342 | CLANG_WARN_ENUM_CONVERSION = YES;
343 | CLANG_WARN_INT_CONVERSION = YES;
344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
345 | CLANG_WARN_UNREACHABLE_CODE = YES;
346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
348 | COPY_PHASE_STRIP = NO;
349 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
350 | ENABLE_NS_ASSERTIONS = NO;
351 | ENABLE_STRICT_OBJC_MSGSEND = YES;
352 | GCC_C_LANGUAGE_STANDARD = gnu99;
353 | GCC_NO_COMMON_BLOCKS = YES;
354 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
355 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
356 | GCC_WARN_UNDECLARED_SELECTOR = YES;
357 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
358 | GCC_WARN_UNUSED_FUNCTION = YES;
359 | GCC_WARN_UNUSED_VARIABLE = YES;
360 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
361 | MTL_ENABLE_DEBUG_INFO = NO;
362 | SDKROOT = iphoneos;
363 | TARGETED_DEVICE_FAMILY = "1,2";
364 | VALIDATE_PRODUCT = YES;
365 | };
366 | name = Release;
367 | };
368 | 99441BB41B3D040500DC40D8 /* Debug */ = {
369 | isa = XCBuildConfiguration;
370 | buildSettings = {
371 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
372 | INFOPLIST_FILE = P2MSCountDownTimer/Info.plist;
373 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
374 | PRODUCT_BUNDLE_IDENTIFIER = "com.ptwoms.$(PRODUCT_NAME:rfc1034identifier)";
375 | PRODUCT_NAME = "$(TARGET_NAME)";
376 | };
377 | name = Debug;
378 | };
379 | 99441BB51B3D040500DC40D8 /* Release */ = {
380 | isa = XCBuildConfiguration;
381 | buildSettings = {
382 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
383 | INFOPLIST_FILE = P2MSCountDownTimer/Info.plist;
384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
385 | PRODUCT_BUNDLE_IDENTIFIER = "com.ptwoms.$(PRODUCT_NAME:rfc1034identifier)";
386 | PRODUCT_NAME = "$(TARGET_NAME)";
387 | };
388 | name = Release;
389 | };
390 | 99441BB71B3D040500DC40D8 /* Debug */ = {
391 | isa = XCBuildConfiguration;
392 | buildSettings = {
393 | BUNDLE_LOADER = "$(TEST_HOST)";
394 | FRAMEWORK_SEARCH_PATHS = (
395 | "$(SDKROOT)/Developer/Library/Frameworks",
396 | "$(inherited)",
397 | );
398 | GCC_PREPROCESSOR_DEFINITIONS = (
399 | "DEBUG=1",
400 | "$(inherited)",
401 | );
402 | INFOPLIST_FILE = P2MSCountDownTimerTests/Info.plist;
403 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
404 | PRODUCT_BUNDLE_IDENTIFIER = "com.ptwoms.$(PRODUCT_NAME:rfc1034identifier)";
405 | PRODUCT_NAME = "$(TARGET_NAME)";
406 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/P2MSCountDownTimer.app/P2MSCountDownTimer";
407 | };
408 | name = Debug;
409 | };
410 | 99441BB81B3D040500DC40D8 /* Release */ = {
411 | isa = XCBuildConfiguration;
412 | buildSettings = {
413 | BUNDLE_LOADER = "$(TEST_HOST)";
414 | FRAMEWORK_SEARCH_PATHS = (
415 | "$(SDKROOT)/Developer/Library/Frameworks",
416 | "$(inherited)",
417 | );
418 | INFOPLIST_FILE = P2MSCountDownTimerTests/Info.plist;
419 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
420 | PRODUCT_BUNDLE_IDENTIFIER = "com.ptwoms.$(PRODUCT_NAME:rfc1034identifier)";
421 | PRODUCT_NAME = "$(TARGET_NAME)";
422 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/P2MSCountDownTimer.app/P2MSCountDownTimer";
423 | };
424 | name = Release;
425 | };
426 | /* End XCBuildConfiguration section */
427 |
428 | /* Begin XCConfigurationList section */
429 | 99441B8F1B3D040500DC40D8 /* Build configuration list for PBXProject "P2MSCountDownTimer" */ = {
430 | isa = XCConfigurationList;
431 | buildConfigurations = (
432 | 99441BB11B3D040500DC40D8 /* Debug */,
433 | 99441BB21B3D040500DC40D8 /* Release */,
434 | );
435 | defaultConfigurationIsVisible = 0;
436 | defaultConfigurationName = Release;
437 | };
438 | 99441BB31B3D040500DC40D8 /* Build configuration list for PBXNativeTarget "P2MSCountDownTimer" */ = {
439 | isa = XCConfigurationList;
440 | buildConfigurations = (
441 | 99441BB41B3D040500DC40D8 /* Debug */,
442 | 99441BB51B3D040500DC40D8 /* Release */,
443 | );
444 | defaultConfigurationIsVisible = 0;
445 | defaultConfigurationName = Release;
446 | };
447 | 99441BB61B3D040500DC40D8 /* Build configuration list for PBXNativeTarget "P2MSCountDownTimerTests" */ = {
448 | isa = XCConfigurationList;
449 | buildConfigurations = (
450 | 99441BB71B3D040500DC40D8 /* Debug */,
451 | 99441BB81B3D040500DC40D8 /* Release */,
452 | );
453 | defaultConfigurationIsVisible = 0;
454 | defaultConfigurationName = Release;
455 | };
456 | /* End XCConfigurationList section */
457 | };
458 | rootObject = 99441B8C1B3D040500DC40D8 /* Project object */;
459 | }
460 |
--------------------------------------------------------------------------------