├── .gitignore
├── LICENSE
├── README.md
├── img
└── img1.png
├── ios_swift_drawing_app.xcodeproj
├── project.pbxproj
└── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── ios_swift_drawing_app
├── AppDelegate.swift
├── Base.lproj
│ ├── LaunchScreen.xib
│ └── Main.storyboard
├── DrawingView.swift
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
└── ViewController.swift
└── ios_swift_drawing_appTests
├── Info.plist
└── ios_swift_drawing_appTests.swift
/.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 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | # Pods/
27 |
28 | # Carthage
29 | #
30 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
31 | # Carthage/Checkouts
32 |
33 | Carthage/Build
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Maxim Bilan
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
iOS Swift Drawing Application Sample
2 |
3 | A simple example which describes how to draw in the UIView using Swift programming language.
4 | We need to create the class DrawingView inherited from UIView . With the following properties:
5 |
6 | var drawColor = UIColor.blackColor() // A color for drawing
7 | var lineWidth: CGFloat = 5 // A line width
8 |
9 | private var lastPoint: CGPoint! // A point for storing the last position
10 | private var bezierPath: UIBezierPath! // A bezier path
11 | private var pointCounter: Int = 0 // A counter of ponts
12 | private let pointLimit: Int = 128 // A limit of points
13 | private var preRenderImage: UIImage! // A pre-render image
14 |
15 |
16 | First of all, initialization. We need to create UIBezierPath and set up some properties.
17 |
18 |
19 | override init(frame: CGRect) {
20 | super.init(frame: frame)
21 |
22 | initBezierPath()
23 | }
24 |
25 | required init(coder aDecoder: NSCoder) {
26 | super.init(coder: aDecoder)
27 |
28 | initBezierPath()
29 | }
30 |
31 | func initBezierPath() {
32 | bezierPath = UIBezierPath()
33 | bezierPath.lineCapStyle = kCGLineCapRound
34 | bezierPath.lineJoinStyle = kCGLineJoinRound
35 | }
36 |
37 |
38 | For better performance we will store the bezier path rendering to UIImage , so create the function renderToImage .
39 |
40 | func renderToImage() {
41 |
42 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, false, 0.0)
43 | if preRenderImage != nil {
44 | preRenderImage.drawInRect(self.bounds)
45 | }
46 |
47 | bezierPath.lineWidth = lineWidth
48 | drawColor.setFill()
49 | drawColor.setStroke()
50 | bezierPath.stroke()
51 |
52 | preRenderImage = UIGraphicsGetImageFromCurrentImageContext()
53 |
54 | UIGraphicsEndImageContext()
55 | }
56 |
57 |
58 | And implement the rendering function.
59 |
60 | override func drawRect(rect: CGRect) {
61 | super.drawRect(rect)
62 |
63 | if preRenderImage != nil {
64 | preRenderImage.drawInRect(self.bounds)
65 | }
66 |
67 | bezierPath.lineWidth = lineWidth
68 | drawColor.setFill()
69 | drawColor.setStroke()
70 | bezierPath.stroke()
71 | }
72 |
73 |
74 | First, draw the pre-render image and after that render the current bezier path.
75 | Now, main of our application, it's touch handling.
76 |
77 | In touchesBegan function we save the last point and reset the point counter.
78 |
79 |
80 | override func touchesBegan(touches: Set, withEvent event: UIEvent) {
81 | let touch: AnyObject? = touches.first
82 | lastPoint = touch!.locationInView(self)
83 | pointCounter = 0
84 | }
85 |
86 |
87 | In touchesMoved function, add a point to the bezier path, increment the point counter and if the point counter equals a point limit, than render the bezier path to UIImage and reset the bezier path. And update the screen.
88 |
89 |
90 | override func touchesMoved(touches: Set, withEvent event: UIEvent) {
91 | let touch: AnyObject? = touches.first
92 | var newPoint = touch!.locationInView(self)
93 |
94 | bezierPath.moveToPoint(lastPoint)
95 | bezierPath.addLineToPoint(newPoint)
96 | lastPoint = newPoint
97 |
98 | ++pointCounter
99 |
100 | if pointCounter == pointLimit {
101 | pointCounter = 0
102 | renderToImage()
103 | setNeedsDisplay()
104 | bezierPath.removeAllPoints()
105 | }
106 | else {
107 | setNeedsDisplay()
108 | }
109 | }
110 |
111 |
112 | In touchesEnded function reset the pointer counter, render the bezier path to UIImage , reset the bezier path and update the screen.
113 |
114 |
115 | override func touchesEnded(touches: Set, withEvent event: UIEvent) {
116 | pointCounter = 0
117 | renderToImage()
118 | setNeedsDisplay()
119 | bezierPath.removeAllPoints()
120 | }
121 |
122 |
123 | In touchesCancelled function just call touchesEnded .
124 |
125 |
126 | override func touchesCancelled(touches: Set!, withEvent event: UIEvent!) {
127 | touchesEnded(touches, withEvent: event)
128 | }
129 |
130 |
131 | For clearing the view we need remove all points from the bezier path, reset the pre-render image and update the display:
132 |
133 |
134 | func clear() {
135 | preRenderImage = nil
136 | bezierPath.removeAllPoints()
137 | setNeedsDisplay()
138 | }
139 |
140 |
141 | And for checking lines on the view:
142 |
143 |
144 | func hasLines() -> Bool {
145 | return preRenderImage != nil || !bezierPath.empty
146 | }
147 |
148 |
149 | That's all and we have really simple drawing application written by Swift .
150 |
--------------------------------------------------------------------------------
/img/img1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maximbilan/iOS-Swift-Drawing-App/cd599ac4be90245c399d05252c18bdc4365384a2/img/img1.png
--------------------------------------------------------------------------------
/ios_swift_drawing_app.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 6D78A2621AF0BBBA0092EE1A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D78A2611AF0BBBA0092EE1A /* AppDelegate.swift */; };
11 | 6D78A2641AF0BBBA0092EE1A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D78A2631AF0BBBA0092EE1A /* ViewController.swift */; };
12 | 6D78A2671AF0BBBA0092EE1A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D78A2651AF0BBBA0092EE1A /* Main.storyboard */; };
13 | 6D78A2691AF0BBBA0092EE1A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D78A2681AF0BBBA0092EE1A /* Images.xcassets */; };
14 | 6D78A26C1AF0BBBA0092EE1A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D78A26A1AF0BBBA0092EE1A /* LaunchScreen.xib */; };
15 | 6D78A2781AF0BBBA0092EE1A /* ios_swift_drawing_appTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D78A2771AF0BBBA0092EE1A /* ios_swift_drawing_appTests.swift */; };
16 | 6D78A2841AF0BFAC0092EE1A /* DrawingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D78A2831AF0BFAC0092EE1A /* DrawingView.swift */; };
17 | /* End PBXBuildFile section */
18 |
19 | /* Begin PBXContainerItemProxy section */
20 | 6D78A2721AF0BBBA0092EE1A /* PBXContainerItemProxy */ = {
21 | isa = PBXContainerItemProxy;
22 | containerPortal = 6D78A2541AF0BBBA0092EE1A /* Project object */;
23 | proxyType = 1;
24 | remoteGlobalIDString = 6D78A25B1AF0BBBA0092EE1A;
25 | remoteInfo = ios_swift_drawing_app;
26 | };
27 | /* End PBXContainerItemProxy section */
28 |
29 | /* Begin PBXFileReference section */
30 | 6D78A25C1AF0BBBA0092EE1A /* ios_swift_drawing_app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ios_swift_drawing_app.app; sourceTree = BUILT_PRODUCTS_DIR; };
31 | 6D78A2601AF0BBBA0092EE1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
32 | 6D78A2611AF0BBBA0092EE1A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
33 | 6D78A2631AF0BBBA0092EE1A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
34 | 6D78A2661AF0BBBA0092EE1A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
35 | 6D78A2681AF0BBBA0092EE1A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
36 | 6D78A26B1AF0BBBA0092EE1A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
37 | 6D78A2711AF0BBBA0092EE1A /* ios_swift_drawing_appTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ios_swift_drawing_appTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
38 | 6D78A2761AF0BBBA0092EE1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
39 | 6D78A2771AF0BBBA0092EE1A /* ios_swift_drawing_appTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ios_swift_drawing_appTests.swift; sourceTree = ""; };
40 | 6D78A2831AF0BFAC0092EE1A /* DrawingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DrawingView.swift; sourceTree = ""; };
41 | /* End PBXFileReference section */
42 |
43 | /* Begin PBXFrameworksBuildPhase section */
44 | 6D78A2591AF0BBBA0092EE1A /* Frameworks */ = {
45 | isa = PBXFrameworksBuildPhase;
46 | buildActionMask = 2147483647;
47 | files = (
48 | );
49 | runOnlyForDeploymentPostprocessing = 0;
50 | };
51 | 6D78A26E1AF0BBBA0092EE1A /* Frameworks */ = {
52 | isa = PBXFrameworksBuildPhase;
53 | buildActionMask = 2147483647;
54 | files = (
55 | );
56 | runOnlyForDeploymentPostprocessing = 0;
57 | };
58 | /* End PBXFrameworksBuildPhase section */
59 |
60 | /* Begin PBXGroup section */
61 | 6D78A2531AF0BBBA0092EE1A = {
62 | isa = PBXGroup;
63 | children = (
64 | 6D78A25E1AF0BBBA0092EE1A /* ios_swift_drawing_app */,
65 | 6D78A2741AF0BBBA0092EE1A /* ios_swift_drawing_appTests */,
66 | 6D78A25D1AF0BBBA0092EE1A /* Products */,
67 | );
68 | sourceTree = "";
69 | };
70 | 6D78A25D1AF0BBBA0092EE1A /* Products */ = {
71 | isa = PBXGroup;
72 | children = (
73 | 6D78A25C1AF0BBBA0092EE1A /* ios_swift_drawing_app.app */,
74 | 6D78A2711AF0BBBA0092EE1A /* ios_swift_drawing_appTests.xctest */,
75 | );
76 | name = Products;
77 | sourceTree = "";
78 | };
79 | 6D78A25E1AF0BBBA0092EE1A /* ios_swift_drawing_app */ = {
80 | isa = PBXGroup;
81 | children = (
82 | 6D78A2611AF0BBBA0092EE1A /* AppDelegate.swift */,
83 | 6D78A2631AF0BBBA0092EE1A /* ViewController.swift */,
84 | 6D78A2831AF0BFAC0092EE1A /* DrawingView.swift */,
85 | 6D78A2651AF0BBBA0092EE1A /* Main.storyboard */,
86 | 6D78A2681AF0BBBA0092EE1A /* Images.xcassets */,
87 | 6D78A26A1AF0BBBA0092EE1A /* LaunchScreen.xib */,
88 | 6D78A25F1AF0BBBA0092EE1A /* Supporting Files */,
89 | );
90 | path = ios_swift_drawing_app;
91 | sourceTree = "";
92 | };
93 | 6D78A25F1AF0BBBA0092EE1A /* Supporting Files */ = {
94 | isa = PBXGroup;
95 | children = (
96 | 6D78A2601AF0BBBA0092EE1A /* Info.plist */,
97 | );
98 | name = "Supporting Files";
99 | sourceTree = "";
100 | };
101 | 6D78A2741AF0BBBA0092EE1A /* ios_swift_drawing_appTests */ = {
102 | isa = PBXGroup;
103 | children = (
104 | 6D78A2771AF0BBBA0092EE1A /* ios_swift_drawing_appTests.swift */,
105 | 6D78A2751AF0BBBA0092EE1A /* Supporting Files */,
106 | );
107 | path = ios_swift_drawing_appTests;
108 | sourceTree = "";
109 | };
110 | 6D78A2751AF0BBBA0092EE1A /* Supporting Files */ = {
111 | isa = PBXGroup;
112 | children = (
113 | 6D78A2761AF0BBBA0092EE1A /* Info.plist */,
114 | );
115 | name = "Supporting Files";
116 | sourceTree = "";
117 | };
118 | /* End PBXGroup section */
119 |
120 | /* Begin PBXNativeTarget section */
121 | 6D78A25B1AF0BBBA0092EE1A /* ios_swift_drawing_app */ = {
122 | isa = PBXNativeTarget;
123 | buildConfigurationList = 6D78A27B1AF0BBBA0092EE1A /* Build configuration list for PBXNativeTarget "ios_swift_drawing_app" */;
124 | buildPhases = (
125 | 6D78A2581AF0BBBA0092EE1A /* Sources */,
126 | 6D78A2591AF0BBBA0092EE1A /* Frameworks */,
127 | 6D78A25A1AF0BBBA0092EE1A /* Resources */,
128 | );
129 | buildRules = (
130 | );
131 | dependencies = (
132 | );
133 | name = ios_swift_drawing_app;
134 | productName = ios_swift_drawing_app;
135 | productReference = 6D78A25C1AF0BBBA0092EE1A /* ios_swift_drawing_app.app */;
136 | productType = "com.apple.product-type.application";
137 | };
138 | 6D78A2701AF0BBBA0092EE1A /* ios_swift_drawing_appTests */ = {
139 | isa = PBXNativeTarget;
140 | buildConfigurationList = 6D78A27E1AF0BBBA0092EE1A /* Build configuration list for PBXNativeTarget "ios_swift_drawing_appTests" */;
141 | buildPhases = (
142 | 6D78A26D1AF0BBBA0092EE1A /* Sources */,
143 | 6D78A26E1AF0BBBA0092EE1A /* Frameworks */,
144 | 6D78A26F1AF0BBBA0092EE1A /* Resources */,
145 | );
146 | buildRules = (
147 | );
148 | dependencies = (
149 | 6D78A2731AF0BBBA0092EE1A /* PBXTargetDependency */,
150 | );
151 | name = ios_swift_drawing_appTests;
152 | productName = ios_swift_drawing_appTests;
153 | productReference = 6D78A2711AF0BBBA0092EE1A /* ios_swift_drawing_appTests.xctest */;
154 | productType = "com.apple.product-type.bundle.unit-test";
155 | };
156 | /* End PBXNativeTarget section */
157 |
158 | /* Begin PBXProject section */
159 | 6D78A2541AF0BBBA0092EE1A /* Project object */ = {
160 | isa = PBXProject;
161 | attributes = {
162 | LastSwiftMigration = 0700;
163 | LastSwiftUpdateCheck = 0700;
164 | LastUpgradeCheck = 1000;
165 | ORGANIZATIONNAME = "Maxim Bilan";
166 | TargetAttributes = {
167 | 6D78A25B1AF0BBBA0092EE1A = {
168 | CreatedOnToolsVersion = 6.3.1;
169 | LastSwiftMigration = 1000;
170 | };
171 | 6D78A2701AF0BBBA0092EE1A = {
172 | CreatedOnToolsVersion = 6.3.1;
173 | LastSwiftMigration = 1000;
174 | TestTargetID = 6D78A25B1AF0BBBA0092EE1A;
175 | };
176 | };
177 | };
178 | buildConfigurationList = 6D78A2571AF0BBBA0092EE1A /* Build configuration list for PBXProject "ios_swift_drawing_app" */;
179 | compatibilityVersion = "Xcode 3.2";
180 | developmentRegion = English;
181 | hasScannedForEncodings = 0;
182 | knownRegions = (
183 | en,
184 | Base,
185 | );
186 | mainGroup = 6D78A2531AF0BBBA0092EE1A;
187 | productRefGroup = 6D78A25D1AF0BBBA0092EE1A /* Products */;
188 | projectDirPath = "";
189 | projectRoot = "";
190 | targets = (
191 | 6D78A25B1AF0BBBA0092EE1A /* ios_swift_drawing_app */,
192 | 6D78A2701AF0BBBA0092EE1A /* ios_swift_drawing_appTests */,
193 | );
194 | };
195 | /* End PBXProject section */
196 |
197 | /* Begin PBXResourcesBuildPhase section */
198 | 6D78A25A1AF0BBBA0092EE1A /* Resources */ = {
199 | isa = PBXResourcesBuildPhase;
200 | buildActionMask = 2147483647;
201 | files = (
202 | 6D78A2671AF0BBBA0092EE1A /* Main.storyboard in Resources */,
203 | 6D78A26C1AF0BBBA0092EE1A /* LaunchScreen.xib in Resources */,
204 | 6D78A2691AF0BBBA0092EE1A /* Images.xcassets in Resources */,
205 | );
206 | runOnlyForDeploymentPostprocessing = 0;
207 | };
208 | 6D78A26F1AF0BBBA0092EE1A /* Resources */ = {
209 | isa = PBXResourcesBuildPhase;
210 | buildActionMask = 2147483647;
211 | files = (
212 | );
213 | runOnlyForDeploymentPostprocessing = 0;
214 | };
215 | /* End PBXResourcesBuildPhase section */
216 |
217 | /* Begin PBXSourcesBuildPhase section */
218 | 6D78A2581AF0BBBA0092EE1A /* Sources */ = {
219 | isa = PBXSourcesBuildPhase;
220 | buildActionMask = 2147483647;
221 | files = (
222 | 6D78A2841AF0BFAC0092EE1A /* DrawingView.swift in Sources */,
223 | 6D78A2641AF0BBBA0092EE1A /* ViewController.swift in Sources */,
224 | 6D78A2621AF0BBBA0092EE1A /* AppDelegate.swift in Sources */,
225 | );
226 | runOnlyForDeploymentPostprocessing = 0;
227 | };
228 | 6D78A26D1AF0BBBA0092EE1A /* Sources */ = {
229 | isa = PBXSourcesBuildPhase;
230 | buildActionMask = 2147483647;
231 | files = (
232 | 6D78A2781AF0BBBA0092EE1A /* ios_swift_drawing_appTests.swift in Sources */,
233 | );
234 | runOnlyForDeploymentPostprocessing = 0;
235 | };
236 | /* End PBXSourcesBuildPhase section */
237 |
238 | /* Begin PBXTargetDependency section */
239 | 6D78A2731AF0BBBA0092EE1A /* PBXTargetDependency */ = {
240 | isa = PBXTargetDependency;
241 | target = 6D78A25B1AF0BBBA0092EE1A /* ios_swift_drawing_app */;
242 | targetProxy = 6D78A2721AF0BBBA0092EE1A /* PBXContainerItemProxy */;
243 | };
244 | /* End PBXTargetDependency section */
245 |
246 | /* Begin PBXVariantGroup section */
247 | 6D78A2651AF0BBBA0092EE1A /* Main.storyboard */ = {
248 | isa = PBXVariantGroup;
249 | children = (
250 | 6D78A2661AF0BBBA0092EE1A /* Base */,
251 | );
252 | name = Main.storyboard;
253 | sourceTree = "";
254 | };
255 | 6D78A26A1AF0BBBA0092EE1A /* LaunchScreen.xib */ = {
256 | isa = PBXVariantGroup;
257 | children = (
258 | 6D78A26B1AF0BBBA0092EE1A /* Base */,
259 | );
260 | name = LaunchScreen.xib;
261 | sourceTree = "";
262 | };
263 | /* End PBXVariantGroup section */
264 |
265 | /* Begin XCBuildConfiguration section */
266 | 6D78A2791AF0BBBA0092EE1A /* Debug */ = {
267 | isa = XCBuildConfiguration;
268 | buildSettings = {
269 | ALWAYS_SEARCH_USER_PATHS = NO;
270 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
271 | CLANG_CXX_LIBRARY = "libc++";
272 | CLANG_ENABLE_MODULES = YES;
273 | CLANG_ENABLE_OBJC_ARC = YES;
274 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
275 | CLANG_WARN_BOOL_CONVERSION = YES;
276 | CLANG_WARN_COMMA = YES;
277 | CLANG_WARN_CONSTANT_CONVERSION = YES;
278 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
279 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
280 | CLANG_WARN_EMPTY_BODY = YES;
281 | CLANG_WARN_ENUM_CONVERSION = YES;
282 | CLANG_WARN_INFINITE_RECURSION = YES;
283 | CLANG_WARN_INT_CONVERSION = YES;
284 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
285 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
286 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
288 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
289 | CLANG_WARN_STRICT_PROTOTYPES = YES;
290 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
291 | CLANG_WARN_UNREACHABLE_CODE = YES;
292 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
293 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
294 | COPY_PHASE_STRIP = NO;
295 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
296 | ENABLE_STRICT_OBJC_MSGSEND = YES;
297 | ENABLE_TESTABILITY = YES;
298 | GCC_C_LANGUAGE_STANDARD = gnu99;
299 | GCC_DYNAMIC_NO_PIC = NO;
300 | GCC_NO_COMMON_BLOCKS = YES;
301 | GCC_OPTIMIZATION_LEVEL = 0;
302 | GCC_PREPROCESSOR_DEFINITIONS = (
303 | "DEBUG=1",
304 | "$(inherited)",
305 | );
306 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
307 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
308 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
309 | GCC_WARN_UNDECLARED_SELECTOR = YES;
310 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
311 | GCC_WARN_UNUSED_FUNCTION = YES;
312 | GCC_WARN_UNUSED_VARIABLE = YES;
313 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
314 | MTL_ENABLE_DEBUG_INFO = YES;
315 | ONLY_ACTIVE_ARCH = YES;
316 | SDKROOT = iphoneos;
317 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
318 | TARGETED_DEVICE_FAMILY = "1,2";
319 | };
320 | name = Debug;
321 | };
322 | 6D78A27A1AF0BBBA0092EE1A /* Release */ = {
323 | isa = XCBuildConfiguration;
324 | buildSettings = {
325 | ALWAYS_SEARCH_USER_PATHS = NO;
326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
327 | CLANG_CXX_LIBRARY = "libc++";
328 | CLANG_ENABLE_MODULES = YES;
329 | CLANG_ENABLE_OBJC_ARC = YES;
330 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
331 | CLANG_WARN_BOOL_CONVERSION = YES;
332 | CLANG_WARN_COMMA = YES;
333 | CLANG_WARN_CONSTANT_CONVERSION = YES;
334 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
335 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
336 | CLANG_WARN_EMPTY_BODY = YES;
337 | CLANG_WARN_ENUM_CONVERSION = YES;
338 | CLANG_WARN_INFINITE_RECURSION = YES;
339 | CLANG_WARN_INT_CONVERSION = YES;
340 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
341 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
342 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
344 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
345 | CLANG_WARN_STRICT_PROTOTYPES = YES;
346 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
347 | CLANG_WARN_UNREACHABLE_CODE = YES;
348 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
349 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
350 | COPY_PHASE_STRIP = NO;
351 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
352 | ENABLE_NS_ASSERTIONS = NO;
353 | ENABLE_STRICT_OBJC_MSGSEND = YES;
354 | GCC_C_LANGUAGE_STANDARD = gnu99;
355 | GCC_NO_COMMON_BLOCKS = YES;
356 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
357 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
358 | GCC_WARN_UNDECLARED_SELECTOR = YES;
359 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
360 | GCC_WARN_UNUSED_FUNCTION = YES;
361 | GCC_WARN_UNUSED_VARIABLE = YES;
362 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
363 | MTL_ENABLE_DEBUG_INFO = NO;
364 | SDKROOT = iphoneos;
365 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
366 | TARGETED_DEVICE_FAMILY = "1,2";
367 | VALIDATE_PRODUCT = YES;
368 | };
369 | name = Release;
370 | };
371 | 6D78A27C1AF0BBBA0092EE1A /* Debug */ = {
372 | isa = XCBuildConfiguration;
373 | buildSettings = {
374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
375 | INFOPLIST_FILE = ios_swift_drawing_app/Info.plist;
376 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
377 | PRODUCT_BUNDLE_IDENTIFIER = "maximbilan.$(PRODUCT_NAME:rfc1034identifier)";
378 | PRODUCT_NAME = "$(TARGET_NAME)";
379 | SWIFT_VERSION = 4.2;
380 | };
381 | name = Debug;
382 | };
383 | 6D78A27D1AF0BBBA0092EE1A /* Release */ = {
384 | isa = XCBuildConfiguration;
385 | buildSettings = {
386 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
387 | INFOPLIST_FILE = ios_swift_drawing_app/Info.plist;
388 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
389 | PRODUCT_BUNDLE_IDENTIFIER = "maximbilan.$(PRODUCT_NAME:rfc1034identifier)";
390 | PRODUCT_NAME = "$(TARGET_NAME)";
391 | SWIFT_VERSION = 4.2;
392 | };
393 | name = Release;
394 | };
395 | 6D78A27F1AF0BBBA0092EE1A /* Debug */ = {
396 | isa = XCBuildConfiguration;
397 | buildSettings = {
398 | BUNDLE_LOADER = "$(TEST_HOST)";
399 | GCC_PREPROCESSOR_DEFINITIONS = (
400 | "DEBUG=1",
401 | "$(inherited)",
402 | );
403 | INFOPLIST_FILE = ios_swift_drawing_appTests/Info.plist;
404 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
405 | PRODUCT_BUNDLE_IDENTIFIER = "maximbilan.$(PRODUCT_NAME:rfc1034identifier)";
406 | PRODUCT_NAME = "$(TARGET_NAME)";
407 | SWIFT_VERSION = 4.2;
408 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ios_swift_drawing_app.app/ios_swift_drawing_app";
409 | };
410 | name = Debug;
411 | };
412 | 6D78A2801AF0BBBA0092EE1A /* Release */ = {
413 | isa = XCBuildConfiguration;
414 | buildSettings = {
415 | BUNDLE_LOADER = "$(TEST_HOST)";
416 | INFOPLIST_FILE = ios_swift_drawing_appTests/Info.plist;
417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
418 | PRODUCT_BUNDLE_IDENTIFIER = "maximbilan.$(PRODUCT_NAME:rfc1034identifier)";
419 | PRODUCT_NAME = "$(TARGET_NAME)";
420 | SWIFT_VERSION = 4.2;
421 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ios_swift_drawing_app.app/ios_swift_drawing_app";
422 | };
423 | name = Release;
424 | };
425 | /* End XCBuildConfiguration section */
426 |
427 | /* Begin XCConfigurationList section */
428 | 6D78A2571AF0BBBA0092EE1A /* Build configuration list for PBXProject "ios_swift_drawing_app" */ = {
429 | isa = XCConfigurationList;
430 | buildConfigurations = (
431 | 6D78A2791AF0BBBA0092EE1A /* Debug */,
432 | 6D78A27A1AF0BBBA0092EE1A /* Release */,
433 | );
434 | defaultConfigurationIsVisible = 0;
435 | defaultConfigurationName = Release;
436 | };
437 | 6D78A27B1AF0BBBA0092EE1A /* Build configuration list for PBXNativeTarget "ios_swift_drawing_app" */ = {
438 | isa = XCConfigurationList;
439 | buildConfigurations = (
440 | 6D78A27C1AF0BBBA0092EE1A /* Debug */,
441 | 6D78A27D1AF0BBBA0092EE1A /* Release */,
442 | );
443 | defaultConfigurationIsVisible = 0;
444 | defaultConfigurationName = Release;
445 | };
446 | 6D78A27E1AF0BBBA0092EE1A /* Build configuration list for PBXNativeTarget "ios_swift_drawing_appTests" */ = {
447 | isa = XCConfigurationList;
448 | buildConfigurations = (
449 | 6D78A27F1AF0BBBA0092EE1A /* Debug */,
450 | 6D78A2801AF0BBBA0092EE1A /* Release */,
451 | );
452 | defaultConfigurationIsVisible = 0;
453 | defaultConfigurationName = Release;
454 | };
455 | /* End XCConfigurationList section */
456 | };
457 | rootObject = 6D78A2541AF0BBBA0092EE1A /* Project object */;
458 | }
459 |
--------------------------------------------------------------------------------
/ios_swift_drawing_app.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios_swift_drawing_app.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios_swift_drawing_app/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // ios_swift_drawing_app
4 | //
5 | // Created by Maxim Bilan on 4/29/15.
6 | // Copyright (c) 2015 Maxim Bilan. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
17 | return true
18 | }
19 |
20 | func applicationWillResignActive(_ application: UIApplication) {
21 | // 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.
22 | // 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.
23 | }
24 |
25 | func applicationDidEnterBackground(_ application: UIApplication) {
26 | // 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.
27 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
28 | }
29 |
30 | func applicationWillEnterForeground(_ application: UIApplication) {
31 | // 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.
32 | }
33 |
34 | func applicationDidBecomeActive(_ application: UIApplication) {
35 | // 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.
36 | }
37 |
38 | func applicationWillTerminate(_ application: UIApplication) {
39 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
40 | }
41 |
42 |
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/ios_swift_drawing_app/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ios_swift_drawing_app/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ios_swift_drawing_app/DrawingView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DrawingView.swift
3 | // ios_swift_drawing_app
4 | //
5 | // Created by Maxim Bilan on 4/29/15.
6 | // Copyright (c) 2015 Maxim Bilan. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class DrawingView: UIView {
12 |
13 | var drawColor = UIColor.black
14 | var lineWidth: CGFloat = 5
15 |
16 | private var lastPoint: CGPoint!
17 | private var bezierPath: UIBezierPath!
18 | private var pointCounter: Int = 0
19 | private let pointLimit: Int = 128
20 | private var preRenderImage: UIImage!
21 |
22 | // MARK: - Initialization
23 |
24 | override init(frame: CGRect) {
25 | super.init(frame: frame)
26 |
27 | initBezierPath()
28 | }
29 |
30 | required init?(coder aDecoder: NSCoder) {
31 | super.init(coder: aDecoder)
32 |
33 | initBezierPath()
34 | }
35 |
36 | func initBezierPath() {
37 | bezierPath = UIBezierPath()
38 | bezierPath.lineCapStyle = CGLineCap.round
39 | bezierPath.lineJoinStyle = CGLineJoin.round
40 | }
41 |
42 | // MARK: - Touch handling
43 |
44 | override func touchesBegan(_ touches: Set, with event: UIEvent?) {
45 | let touch: AnyObject? = touches.first
46 | lastPoint = touch!.location(in: self)
47 | pointCounter = 0
48 | }
49 |
50 | override func touchesMoved(_ touches: Set, with event: UIEvent?) {
51 | let touch: AnyObject? = touches.first
52 | let newPoint = touch!.location(in: self)
53 |
54 | bezierPath.move(to: lastPoint)
55 | bezierPath.addLine(to: newPoint)
56 | lastPoint = newPoint
57 |
58 | pointCounter += 1
59 |
60 | if pointCounter == pointLimit {
61 | pointCounter = 0
62 | renderToImage()
63 | setNeedsDisplay()
64 | bezierPath.removeAllPoints()
65 | }
66 | else {
67 | setNeedsDisplay()
68 | }
69 | }
70 |
71 | override func touchesEnded(_ touches: Set, with event: UIEvent?) {
72 | pointCounter = 0
73 | renderToImage()
74 | setNeedsDisplay()
75 | bezierPath.removeAllPoints()
76 | }
77 |
78 | override func touchesCancelled(_ touches: Set?, with event: UIEvent?) {
79 | touchesEnded(touches!, with: event)
80 | }
81 |
82 | // MARK: - Pre render
83 |
84 | func renderToImage() {
85 |
86 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, false, 0.0)
87 | if preRenderImage != nil {
88 | preRenderImage.draw(in: self.bounds)
89 | }
90 |
91 | bezierPath.lineWidth = lineWidth
92 | drawColor.setFill()
93 | drawColor.setStroke()
94 | bezierPath.stroke()
95 |
96 | preRenderImage = UIGraphicsGetImageFromCurrentImageContext()
97 |
98 | UIGraphicsEndImageContext()
99 | }
100 |
101 | // MARK: - Render
102 |
103 | override func draw(_ rect: CGRect) {
104 | super.draw(rect)
105 |
106 | if preRenderImage != nil {
107 | preRenderImage.draw(in: self.bounds)
108 | }
109 |
110 | bezierPath.lineWidth = lineWidth
111 | drawColor.setFill()
112 | drawColor.setStroke()
113 | bezierPath.stroke()
114 | }
115 |
116 | // MARK: - Clearing
117 |
118 | func clear() {
119 | preRenderImage = nil
120 | bezierPath.removeAllPoints()
121 | setNeedsDisplay()
122 | }
123 |
124 | // MARK: - Other
125 |
126 | func hasLines() -> Bool {
127 | return preRenderImage != nil || !bezierPath.isEmpty
128 | }
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/ios_swift_drawing_app/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 | }
--------------------------------------------------------------------------------
/ios_swift_drawing_app/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 |
--------------------------------------------------------------------------------
/ios_swift_drawing_app/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // ios_swift_drawing_app
4 | //
5 | // Created by Maxim Bilan on 4/29/15.
6 | // Copyright (c) 2015 Maxim Bilan. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ViewController: UIViewController {
12 |
13 | @IBOutlet weak var drawingView: DrawingView!
14 |
15 | override func viewDidLoad() {
16 | super.viewDidLoad()
17 | // Do any additional setup after loading the view, typically from a nib.
18 | }
19 |
20 | override func didReceiveMemoryWarning() {
21 | super.didReceiveMemoryWarning()
22 | // Dispose of any resources that can be recreated.
23 | }
24 |
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/ios_swift_drawing_appTests/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 |
--------------------------------------------------------------------------------
/ios_swift_drawing_appTests/ios_swift_drawing_appTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ios_swift_drawing_appTests.swift
3 | // ios_swift_drawing_appTests
4 | //
5 | // Created by Maxim Bilan on 4/29/15.
6 | // Copyright (c) 2015 Maxim Bilan. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import XCTest
11 |
12 | class ios_swift_drawing_appTests: 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.measure() {
32 | // Put the code you want to measure the time of here.
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------