├── .DS_Store
├── .gitignore
├── .swiftpm
└── xcode
│ └── package.xcworkspace
│ └── contents.xcworkspacedata
├── Example
├── .DS_Store
├── Example.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── Example
│ ├── Assets.xcassets
│ ├── AccentColor.colorset
│ │ └── Contents.json
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Contents.json
│ └── ants.imageset
│ │ ├── Contents.json
│ │ └── maxresdefault.jpg
│ ├── ContentView.swift
│ ├── ExampleApp.swift
│ ├── Preview Content
│ └── Preview Assets.xcassets
│ │ └── Contents.json
│ └── Sigh.swift
├── LICENSE
├── Package.swift
├── README.md
├── Sources
├── .DS_Store
└── AntsInMyPants
│ ├── AntiAliasedRectangle.swift
│ ├── AntsInMyPants.swift
│ ├── ContentSizeObserver.swift
│ ├── DisplayLink.swift
│ └── Radians.swift
└── tilt.gif
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaredsinclair/antsinmypants/d736a5d569bacc143f0f08eea8edc84e83e37e3e/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## User settings
6 | xcuserdata/
7 |
8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
9 | *.xcscmblueprint
10 | *.xccheckout
11 |
12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
13 | build/
14 | DerivedData/
15 | *.moved-aside
16 | *.pbxuser
17 | !default.pbxuser
18 | *.mode1v3
19 | !default.mode1v3
20 | *.mode2v3
21 | !default.mode2v3
22 | *.perspectivev3
23 | !default.perspectivev3
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 |
28 | ## App packaging
29 | *.ipa
30 | *.dSYM.zip
31 | *.dSYM
32 |
33 | ## Playgrounds
34 | timeline.xctimeline
35 | playground.xcworkspace
36 |
37 | # Swift Package Manager
38 | #
39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
40 | # Packages/
41 | # Package.pins
42 | # Package.resolved
43 | # *.xcodeproj
44 | #
45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
46 | # hence it is not needed unless you have added a package configuration file to your project
47 | # .swiftpm
48 |
49 | .build/
50 |
51 | # CocoaPods
52 | #
53 | # We recommend against adding the Pods directory to your .gitignore. However
54 | # you should judge for yourself, the pros and cons are mentioned at:
55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
56 | #
57 | # Pods/
58 | #
59 | # Add this line if you want to avoid checking in source code from the Xcode workspace
60 | # *.xcworkspace
61 |
62 | # Carthage
63 | #
64 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
65 | # Carthage/Checkouts
66 |
67 | Carthage/Build/
68 |
69 | # Accio dependency management
70 | Dependencies/
71 | .accio/
72 |
73 | # fastlane
74 | #
75 | # It is recommended to not store the screenshots in the git repo.
76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed.
77 | # For more information about the recommended setup visit:
78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
79 |
80 | fastlane/report.xml
81 | fastlane/Preview.html
82 | fastlane/screenshots/**/*.png
83 | fastlane/test_output
84 |
85 | # Code Injection
86 | #
87 | # After new code Injection tools there's a generated folder /iOSInjectionProject
88 | # https://github.com/johnno1962/injectionforxcode
89 |
90 | iOSInjectionProject/
91 |
92 | # Sigh...
93 | *.DS_Store
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaredsinclair/antsinmypants/d736a5d569bacc143f0f08eea8edc84e83e37e3e/Example/.DS_Store
--------------------------------------------------------------------------------
/Example/Example.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 55;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 7F845A8B289DF663009C1D3C /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F845A8A289DF663009C1D3C /* ExampleApp.swift */; };
11 | 7F845A8D289DF663009C1D3C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F845A8C289DF663009C1D3C /* ContentView.swift */; };
12 | 7F845A8F289DF664009C1D3C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7F845A8E289DF664009C1D3C /* Assets.xcassets */; };
13 | 7F845A92289DF664009C1D3C /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7F845A91289DF664009C1D3C /* Preview Assets.xcassets */; };
14 | 7F87BE6D289DF79800335264 /* antsinmypants in Resources */ = {isa = PBXBuildFile; fileRef = 7F87BE6C289DF79800335264 /* antsinmypants */; };
15 | 7F87BE70289DF7C400335264 /* AntsInMyPants in Frameworks */ = {isa = PBXBuildFile; productRef = 7F87BE6F289DF7C400335264 /* AntsInMyPants */; };
16 | 7F87BE74289E010000335264 /* Sigh.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F87BE73289E010000335264 /* Sigh.swift */; };
17 | /* End PBXBuildFile section */
18 |
19 | /* Begin PBXFileReference section */
20 | 7F845A87289DF663009C1D3C /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
21 | 7F845A8A289DF663009C1D3C /* ExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleApp.swift; sourceTree = ""; };
22 | 7F845A8C289DF663009C1D3C /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; };
23 | 7F845A8E289DF664009C1D3C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
24 | 7F845A91289DF664009C1D3C /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; };
25 | 7F87BE6C289DF79800335264 /* antsinmypants */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = antsinmypants; path = ..; sourceTree = ""; };
26 | 7F87BE73289E010000335264 /* Sigh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sigh.swift; sourceTree = ""; };
27 | /* End PBXFileReference section */
28 |
29 | /* Begin PBXFrameworksBuildPhase section */
30 | 7F845A84289DF663009C1D3C /* Frameworks */ = {
31 | isa = PBXFrameworksBuildPhase;
32 | buildActionMask = 2147483647;
33 | files = (
34 | 7F87BE70289DF7C400335264 /* AntsInMyPants in Frameworks */,
35 | );
36 | runOnlyForDeploymentPostprocessing = 0;
37 | };
38 | /* End PBXFrameworksBuildPhase section */
39 |
40 | /* Begin PBXGroup section */
41 | 7F845A7E289DF663009C1D3C = {
42 | isa = PBXGroup;
43 | children = (
44 | 7F87BE6C289DF79800335264 /* antsinmypants */,
45 | 7F845A89289DF663009C1D3C /* Example */,
46 | 7F845A88289DF663009C1D3C /* Products */,
47 | 7F87BE6E289DF7C400335264 /* Frameworks */,
48 | );
49 | sourceTree = "";
50 | };
51 | 7F845A88289DF663009C1D3C /* Products */ = {
52 | isa = PBXGroup;
53 | children = (
54 | 7F845A87289DF663009C1D3C /* Example.app */,
55 | );
56 | name = Products;
57 | sourceTree = "";
58 | };
59 | 7F845A89289DF663009C1D3C /* Example */ = {
60 | isa = PBXGroup;
61 | children = (
62 | 7F845A8A289DF663009C1D3C /* ExampleApp.swift */,
63 | 7F845A8C289DF663009C1D3C /* ContentView.swift */,
64 | 7F87BE73289E010000335264 /* Sigh.swift */,
65 | 7F845A8E289DF664009C1D3C /* Assets.xcassets */,
66 | 7F845A90289DF664009C1D3C /* Preview Content */,
67 | );
68 | path = Example;
69 | sourceTree = "";
70 | };
71 | 7F845A90289DF664009C1D3C /* Preview Content */ = {
72 | isa = PBXGroup;
73 | children = (
74 | 7F845A91289DF664009C1D3C /* Preview Assets.xcassets */,
75 | );
76 | path = "Preview Content";
77 | sourceTree = "";
78 | };
79 | 7F87BE6E289DF7C400335264 /* Frameworks */ = {
80 | isa = PBXGroup;
81 | children = (
82 | );
83 | name = Frameworks;
84 | sourceTree = "";
85 | };
86 | /* End PBXGroup section */
87 |
88 | /* Begin PBXNativeTarget section */
89 | 7F845A86289DF663009C1D3C /* Example */ = {
90 | isa = PBXNativeTarget;
91 | buildConfigurationList = 7F845A95289DF664009C1D3C /* Build configuration list for PBXNativeTarget "Example" */;
92 | buildPhases = (
93 | 7F845A83289DF663009C1D3C /* Sources */,
94 | 7F845A84289DF663009C1D3C /* Frameworks */,
95 | 7F845A85289DF663009C1D3C /* Resources */,
96 | );
97 | buildRules = (
98 | );
99 | dependencies = (
100 | );
101 | name = Example;
102 | packageProductDependencies = (
103 | 7F87BE6F289DF7C400335264 /* AntsInMyPants */,
104 | );
105 | productName = Example;
106 | productReference = 7F845A87289DF663009C1D3C /* Example.app */;
107 | productType = "com.apple.product-type.application";
108 | };
109 | /* End PBXNativeTarget section */
110 |
111 | /* Begin PBXProject section */
112 | 7F845A7F289DF663009C1D3C /* Project object */ = {
113 | isa = PBXProject;
114 | attributes = {
115 | BuildIndependentTargetsInParallel = 1;
116 | LastSwiftUpdateCheck = 1340;
117 | LastUpgradeCheck = 1340;
118 | TargetAttributes = {
119 | 7F845A86289DF663009C1D3C = {
120 | CreatedOnToolsVersion = 13.4;
121 | };
122 | };
123 | };
124 | buildConfigurationList = 7F845A82289DF663009C1D3C /* Build configuration list for PBXProject "Example" */;
125 | compatibilityVersion = "Xcode 13.0";
126 | developmentRegion = en;
127 | hasScannedForEncodings = 0;
128 | knownRegions = (
129 | en,
130 | Base,
131 | );
132 | mainGroup = 7F845A7E289DF663009C1D3C;
133 | productRefGroup = 7F845A88289DF663009C1D3C /* Products */;
134 | projectDirPath = "";
135 | projectRoot = "";
136 | targets = (
137 | 7F845A86289DF663009C1D3C /* Example */,
138 | );
139 | };
140 | /* End PBXProject section */
141 |
142 | /* Begin PBXResourcesBuildPhase section */
143 | 7F845A85289DF663009C1D3C /* Resources */ = {
144 | isa = PBXResourcesBuildPhase;
145 | buildActionMask = 2147483647;
146 | files = (
147 | 7F845A92289DF664009C1D3C /* Preview Assets.xcassets in Resources */,
148 | 7F845A8F289DF664009C1D3C /* Assets.xcassets in Resources */,
149 | 7F87BE6D289DF79800335264 /* antsinmypants in Resources */,
150 | );
151 | runOnlyForDeploymentPostprocessing = 0;
152 | };
153 | /* End PBXResourcesBuildPhase section */
154 |
155 | /* Begin PBXSourcesBuildPhase section */
156 | 7F845A83289DF663009C1D3C /* Sources */ = {
157 | isa = PBXSourcesBuildPhase;
158 | buildActionMask = 2147483647;
159 | files = (
160 | 7F87BE74289E010000335264 /* Sigh.swift in Sources */,
161 | 7F845A8D289DF663009C1D3C /* ContentView.swift in Sources */,
162 | 7F845A8B289DF663009C1D3C /* ExampleApp.swift in Sources */,
163 | );
164 | runOnlyForDeploymentPostprocessing = 0;
165 | };
166 | /* End PBXSourcesBuildPhase section */
167 |
168 | /* Begin XCBuildConfiguration section */
169 | 7F845A93289DF664009C1D3C /* Debug */ = {
170 | isa = XCBuildConfiguration;
171 | buildSettings = {
172 | ALWAYS_SEARCH_USER_PATHS = NO;
173 | CLANG_ANALYZER_NONNULL = YES;
174 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
175 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
176 | CLANG_ENABLE_MODULES = YES;
177 | CLANG_ENABLE_OBJC_ARC = YES;
178 | CLANG_ENABLE_OBJC_WEAK = YES;
179 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
180 | CLANG_WARN_BOOL_CONVERSION = YES;
181 | CLANG_WARN_COMMA = YES;
182 | CLANG_WARN_CONSTANT_CONVERSION = YES;
183 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
184 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
185 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
186 | CLANG_WARN_EMPTY_BODY = YES;
187 | CLANG_WARN_ENUM_CONVERSION = YES;
188 | CLANG_WARN_INFINITE_RECURSION = YES;
189 | CLANG_WARN_INT_CONVERSION = YES;
190 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
191 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
192 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
193 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
194 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
195 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
196 | CLANG_WARN_STRICT_PROTOTYPES = YES;
197 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
198 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
199 | CLANG_WARN_UNREACHABLE_CODE = YES;
200 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
201 | COPY_PHASE_STRIP = NO;
202 | DEBUG_INFORMATION_FORMAT = dwarf;
203 | ENABLE_STRICT_OBJC_MSGSEND = YES;
204 | ENABLE_TESTABILITY = YES;
205 | GCC_C_LANGUAGE_STANDARD = gnu11;
206 | GCC_DYNAMIC_NO_PIC = NO;
207 | GCC_NO_COMMON_BLOCKS = YES;
208 | GCC_OPTIMIZATION_LEVEL = 0;
209 | GCC_PREPROCESSOR_DEFINITIONS = (
210 | "DEBUG=1",
211 | "$(inherited)",
212 | );
213 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
214 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
215 | GCC_WARN_UNDECLARED_SELECTOR = YES;
216 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
217 | GCC_WARN_UNUSED_FUNCTION = YES;
218 | GCC_WARN_UNUSED_VARIABLE = YES;
219 | IPHONEOS_DEPLOYMENT_TARGET = 15.5;
220 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
221 | MTL_FAST_MATH = YES;
222 | ONLY_ACTIVE_ARCH = YES;
223 | SDKROOT = iphoneos;
224 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
225 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
226 | };
227 | name = Debug;
228 | };
229 | 7F845A94289DF664009C1D3C /* Release */ = {
230 | isa = XCBuildConfiguration;
231 | buildSettings = {
232 | ALWAYS_SEARCH_USER_PATHS = NO;
233 | CLANG_ANALYZER_NONNULL = YES;
234 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
235 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
236 | CLANG_ENABLE_MODULES = YES;
237 | CLANG_ENABLE_OBJC_ARC = YES;
238 | CLANG_ENABLE_OBJC_WEAK = YES;
239 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
240 | CLANG_WARN_BOOL_CONVERSION = YES;
241 | CLANG_WARN_COMMA = YES;
242 | CLANG_WARN_CONSTANT_CONVERSION = YES;
243 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
244 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
245 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
246 | CLANG_WARN_EMPTY_BODY = YES;
247 | CLANG_WARN_ENUM_CONVERSION = YES;
248 | CLANG_WARN_INFINITE_RECURSION = YES;
249 | CLANG_WARN_INT_CONVERSION = YES;
250 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
251 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
252 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
253 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
254 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
255 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
256 | CLANG_WARN_STRICT_PROTOTYPES = YES;
257 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
258 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
259 | CLANG_WARN_UNREACHABLE_CODE = YES;
260 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
261 | COPY_PHASE_STRIP = NO;
262 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
263 | ENABLE_NS_ASSERTIONS = NO;
264 | ENABLE_STRICT_OBJC_MSGSEND = YES;
265 | GCC_C_LANGUAGE_STANDARD = gnu11;
266 | GCC_NO_COMMON_BLOCKS = YES;
267 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
268 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
269 | GCC_WARN_UNDECLARED_SELECTOR = YES;
270 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
271 | GCC_WARN_UNUSED_FUNCTION = YES;
272 | GCC_WARN_UNUSED_VARIABLE = YES;
273 | IPHONEOS_DEPLOYMENT_TARGET = 15.5;
274 | MTL_ENABLE_DEBUG_INFO = NO;
275 | MTL_FAST_MATH = YES;
276 | SDKROOT = iphoneos;
277 | SWIFT_COMPILATION_MODE = wholemodule;
278 | SWIFT_OPTIMIZATION_LEVEL = "-O";
279 | VALIDATE_PRODUCT = YES;
280 | };
281 | name = Release;
282 | };
283 | 7F845A96289DF664009C1D3C /* Debug */ = {
284 | isa = XCBuildConfiguration;
285 | buildSettings = {
286 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
287 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
288 | CODE_SIGN_STYLE = Automatic;
289 | CURRENT_PROJECT_VERSION = 1;
290 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
291 | DEVELOPMENT_TEAM = 442RNUGV2T;
292 | ENABLE_PREVIEWS = YES;
293 | GENERATE_INFOPLIST_FILE = YES;
294 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
295 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
296 | INFOPLIST_KEY_UILaunchScreen_Generation = YES;
297 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
298 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
299 | LD_RUNPATH_SEARCH_PATHS = (
300 | "$(inherited)",
301 | "@executable_path/Frameworks",
302 | );
303 | MARKETING_VERSION = 1.0;
304 | PRODUCT_BUNDLE_IDENTIFIER = com.niceboy.Example;
305 | PRODUCT_NAME = "$(TARGET_NAME)";
306 | SWIFT_EMIT_LOC_STRINGS = YES;
307 | SWIFT_VERSION = 5.0;
308 | TARGETED_DEVICE_FAMILY = "1,2";
309 | };
310 | name = Debug;
311 | };
312 | 7F845A97289DF664009C1D3C /* Release */ = {
313 | isa = XCBuildConfiguration;
314 | buildSettings = {
315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
316 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
317 | CODE_SIGN_STYLE = Automatic;
318 | CURRENT_PROJECT_VERSION = 1;
319 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
320 | DEVELOPMENT_TEAM = 442RNUGV2T;
321 | ENABLE_PREVIEWS = YES;
322 | GENERATE_INFOPLIST_FILE = YES;
323 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
324 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
325 | INFOPLIST_KEY_UILaunchScreen_Generation = YES;
326 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
327 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
328 | LD_RUNPATH_SEARCH_PATHS = (
329 | "$(inherited)",
330 | "@executable_path/Frameworks",
331 | );
332 | MARKETING_VERSION = 1.0;
333 | PRODUCT_BUNDLE_IDENTIFIER = com.niceboy.Example;
334 | PRODUCT_NAME = "$(TARGET_NAME)";
335 | SWIFT_EMIT_LOC_STRINGS = YES;
336 | SWIFT_VERSION = 5.0;
337 | TARGETED_DEVICE_FAMILY = "1,2";
338 | };
339 | name = Release;
340 | };
341 | /* End XCBuildConfiguration section */
342 |
343 | /* Begin XCConfigurationList section */
344 | 7F845A82289DF663009C1D3C /* Build configuration list for PBXProject "Example" */ = {
345 | isa = XCConfigurationList;
346 | buildConfigurations = (
347 | 7F845A93289DF664009C1D3C /* Debug */,
348 | 7F845A94289DF664009C1D3C /* Release */,
349 | );
350 | defaultConfigurationIsVisible = 0;
351 | defaultConfigurationName = Release;
352 | };
353 | 7F845A95289DF664009C1D3C /* Build configuration list for PBXNativeTarget "Example" */ = {
354 | isa = XCConfigurationList;
355 | buildConfigurations = (
356 | 7F845A96289DF664009C1D3C /* Debug */,
357 | 7F845A97289DF664009C1D3C /* Release */,
358 | );
359 | defaultConfigurationIsVisible = 0;
360 | defaultConfigurationName = Release;
361 | };
362 | /* End XCConfigurationList section */
363 |
364 | /* Begin XCSwiftPackageProductDependency section */
365 | 7F87BE6F289DF7C400335264 /* AntsInMyPants */ = {
366 | isa = XCSwiftPackageProductDependency;
367 | productName = AntsInMyPants;
368 | };
369 | /* End XCSwiftPackageProductDependency section */
370 | };
371 | rootObject = 7F845A7F289DF663009C1D3C /* Project object */;
372 | }
373 |
--------------------------------------------------------------------------------
/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Example/Example/Assets.xcassets/AccentColor.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "scale" : "1x",
46 | "size" : "20x20"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "scale" : "2x",
51 | "size" : "20x20"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "scale" : "1x",
56 | "size" : "29x29"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "scale" : "2x",
61 | "size" : "29x29"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "scale" : "1x",
66 | "size" : "40x40"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "scale" : "2x",
71 | "size" : "40x40"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "scale" : "1x",
76 | "size" : "76x76"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "scale" : "2x",
81 | "size" : "76x76"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "scale" : "2x",
86 | "size" : "83.5x83.5"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "scale" : "1x",
91 | "size" : "1024x1024"
92 | }
93 | ],
94 | "info" : {
95 | "author" : "xcode",
96 | "version" : 1
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/Example/Example/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Example/Assets.xcassets/ants.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "maxresdefault.jpg",
5 | "idiom" : "universal"
6 | }
7 | ],
8 | "info" : {
9 | "author" : "xcode",
10 | "version" : 1
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Example/Example/Assets.xcassets/ants.imageset/maxresdefault.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaredsinclair/antsinmypants/d736a5d569bacc143f0f08eea8edc84e83e37e3e/Example/Example/Assets.xcassets/ants.imageset/maxresdefault.jpg
--------------------------------------------------------------------------------
/Example/Example/ContentView.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 | import AntsInMyPants
3 |
4 | struct ContentView: View {
5 | @State var wiggle: CGFloat = 1.0
6 | @State var iterations: CFTimeInterval = 1.0
7 | @State var perspective: CGFloat = 1.0
8 |
9 | var body: some View {
10 | ReadableContentContainer(emsPerLine: 35) { width in
11 | VStack(spacing: 32) {
12 | AntiAliasedRectangle(cornerRadius: 20) {
13 | Image("ants")
14 | .interpolation(.high)
15 | .resizable()
16 | .aspectRatio(contentMode: .fill)
17 | }
18 | .antsInMyPants(
19 | wiggleExaggeration: $wiggle,
20 | iterationsPerSecond: $iterations,
21 | perspectiveExaggeration: $perspective
22 | )
23 | .shadow(
24 | color: .black.opacity(0.333),
25 | radius: 24, x: 0, y: 24
26 | )
27 |
28 | Text("Hint: try setting the iterations per second to something super slow, around `0.1`, to mimic the animations seen in the iOS and iPadOS home screen widget pickers.")
29 | .foregroundColor(.secondary)
30 |
31 | VStack(spacing: 4) {
32 | HStack {
33 | Text("\(Double(wiggle).formatted(.number.precision(.fractionLength(2))))")
34 | Slider(value: $wiggle, in: 0...5.0)
35 | Image(systemName: "tornado").foregroundColor(.hotPink)
36 | }
37 | HStack {
38 | Text("\(Double(iterations).formatted(.number.precision(.fractionLength(2))))")
39 | Slider(value: $iterations, in: 0...5.0)
40 | Image(systemName: "clock").foregroundColor(.hotPink)
41 | }
42 | HStack {
43 | Text("\(Double(perspective).formatted(.number.precision(.fractionLength(2))))")
44 | Slider(value: $perspective, in: 0...5.0)
45 | Image(systemName: "video").foregroundColor(.hotPink)
46 | }
47 | }
48 | .font(.footnote.monospaced())
49 |
50 | Button {
51 | wiggle = 1
52 | iterations = 1
53 | perspective = 1
54 | } label: {
55 | Label("Reset", systemImage: "arrow.counterclockwise")
56 | }
57 |
58 | }
59 | }
60 | .tint(.hotPink)
61 | }
62 | }
63 |
64 | extension Color {
65 | static var hotPink = Color(.displayP3, red: 1, green: 0, blue: 1, opacity: 1)
66 | }
67 |
68 | struct ContentView_Previews: PreviewProvider {
69 | static var previews: some View {
70 | ContentView()
71 | .previewDevice("iPad Pro (12.9-inch) (5th generation)")
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Example/Example/ExampleApp.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | @main
4 | struct AntsInMyPantsApp: App {
5 | var body: some Scene {
6 | WindowGroup {
7 | ContentView()
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Example/Example/Preview Content/Preview Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Example/Sigh.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 | import Combine
3 |
4 | struct ReadableContentContainer: View {
5 | var emsPerLine: Int = 50
6 | let content: (_ readableContentWidth: CGFloat) -> Content
7 | @StateObject private var fontReference = FontReference()
8 |
9 | var body: some View {
10 | GeometryReader { proxy in
11 | let width = readableContentWidth(in: proxy)
12 | ZStack {
13 | content(width).frame(width: width)
14 | }
15 | .frame(maxWidth: .infinity, maxHeight: .infinity)
16 | }
17 | }
18 |
19 | func readableContentWidth(in proxy: GeometryProxy) -> CGFloat {
20 | let recommended = fontReference.bodyPointSize.rounded() * CGFloat(emsPerLine)
21 | return min(recommended, proxy.size.width - 40)
22 | }
23 | }
24 |
25 | class FontReference: ObservableObject {
26 | @Published var bodyPointSize = UIFont.preferredFont(forTextStyle: .body).pointSize
27 | private var subscription: AnyCancellable?
28 |
29 | init() {
30 | subscription = NotificationCenter.default
31 | .publisher(for: UIContentSizeCategory.didChangeNotification)
32 | .sink { [weak self] _ in
33 | self?.bodyPointSize = UIFont.preferredFont(forTextStyle: .body).pointSize
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Jared Sinclair
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 |
--------------------------------------------------------------------------------
/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.5
2 | // The swift-tools-version declares the minimum version of Swift required to build this package.
3 |
4 | import PackageDescription
5 |
6 | let package = Package(
7 | name: "AntsInMyPants",
8 | platforms: [
9 | .macOS("12"),
10 | .iOS(.v15),
11 | ],
12 | products: [
13 | .library(
14 | name: "AntsInMyPants",
15 | targets: ["AntsInMyPants"]),
16 | ],
17 | targets: [
18 | .target(name: "AntsInMyPants")
19 | ]
20 | )
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AntsInMyPants
2 |
3 | SwiftUI extension for animating arbitrary views using an indefinite wiggle animation like that seen in the iOS and iPadOS home screen widget pickers.
4 |
5 | 
6 |
7 | ## Usage
8 |
9 | See the example app in this repo.
10 |
11 | ## OS Support
12 |
13 | - iOS 15+
14 | - iPadOS 15+
15 | - macOS 12+
16 |
--------------------------------------------------------------------------------
/Sources/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaredsinclair/antsinmypants/d736a5d569bacc143f0f08eea8edc84e83e37e3e/Sources/.DS_Store
--------------------------------------------------------------------------------
/Sources/AntsInMyPants/AntiAliasedRectangle.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | public struct AntiAliasedRectangle: View {
4 | public var cornerRadius: CGFloat
5 | public var rectangleAspectRatio: CGFloat
6 | public let content: () -> Content
7 |
8 | public init(
9 | cornerRadius: CGFloat = 0,
10 | rectangleAspectRatio: CGFloat = 1,
11 | content: @escaping () -> Content
12 | ) {
13 | self.cornerRadius = cornerRadius
14 | self.rectangleAspectRatio = rectangleAspectRatio
15 | self.content = content
16 | }
17 |
18 | public var body: some View {
19 | AspectRatioedRectangle {
20 | AspectRatioedRectangle(
21 | cornerRadius: cornerRadius,
22 | rectangleAspectRatio: rectangleAspectRatio,
23 | content: content
24 | )
25 | .padding(1)
26 | }
27 | .padding(-1)
28 | }
29 | }
30 |
31 | struct AspectRatioedRectangle: View {
32 | var cornerRadius: CGFloat = 0
33 | var rectangleAspectRatio: CGFloat = 1
34 | let content: () -> Content
35 |
36 | var body: some View {
37 | Rectangle()
38 | .foregroundColor(.clear)
39 | .aspectRatio(rectangleAspectRatio, contentMode: .fit)
40 | .overlay(content: content)
41 | .cornerRadius(cornerRadius)
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Sources/AntsInMyPants/AntsInMyPants.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | extension View {
4 |
5 | public func antsInMyPants(
6 | isWiggling: Binding = .constant(true),
7 | wiggleExaggeration: Binding = .constant(1.0),
8 | iterationsPerSecond: Binding = .constant(1.0),
9 | perspectiveExaggeration: Binding = .constant(1.0)
10 | ) -> some View {
11 | AntsInMyPants(
12 | isWiggling: isWiggling,
13 | wiggleExaggeration: wiggleExaggeration,
14 | iterationsPerSecond: iterationsPerSecond,
15 | perspectiveExaggeration: perspectiveExaggeration,
16 | content: { self }
17 | )
18 | }
19 |
20 | }
21 |
22 | public struct AntsInMyPants: View {
23 |
24 | @Binding public var isWiggling: Bool
25 | @Binding public var wiggleExaggeration: CGFloat
26 | @Binding public var iterationsPerSecond: CFTimeInterval
27 | @Binding public var perspectiveExaggeration: CGFloat
28 | public let content: () -> Content
29 |
30 | @StateObject private var timer = RotationTimer()
31 | @State private var contentSize: CGSize?
32 |
33 | public var body: some View {
34 | content()
35 | .overlay {
36 | ContentSizeObserver(size: $contentSize)
37 | }
38 | .projectionEffect(transform)
39 | .task(id: isWiggling) {
40 | isWiggling ? timer.start() : timer.stop()
41 | }
42 | .task(id: iterationsPerSecond) {
43 | timer.iterationsPerSecond = iterationsPerSecond
44 | }
45 | }
46 |
47 | private var transform: ProjectionTransform {
48 |
49 | guard let contentSize = contentSize else {
50 | return ProjectionTransform(.identity)
51 | }
52 |
53 | let width = contentSize.width
54 | let height = contentSize.height
55 |
56 | var transform3d = CATransform3DIdentity
57 |
58 | // Set the perspective as a "feels nice" value according to the area.
59 |
60 | transform3d.m34 = (-1 / (width + height)) * perspectiveExaggeration
61 |
62 | // Do some math, the results of which will be used below.
63 |
64 | let baseAngle = 3.radians * wiggleExaggeration
65 | let baseShift = width * height * 0.00005 * wiggleExaggeration
66 | let yAngle, xAngle, yShift, xShift: CGFloat
67 | if width > height {
68 | yAngle = baseAngle * height/width
69 | yShift = -baseShift * height/width
70 | xAngle = baseAngle
71 | xShift = baseShift
72 | } else {
73 | yAngle = baseAngle
74 | yShift = -baseShift
75 | xAngle = baseAngle * width/height
76 | xShift = baseShift * width/height
77 | }
78 |
79 | // These next two transforms point the "face" at the desired focal point
80 | // behind the user's head, like it's watching a ellipse being drawn on a
81 | // chalkboard across a room, or a dog waiting impatiently for dinner.
82 | // The X and Y values are not changed identically. First of all, the X
83 | // curve (as seen in the RotationTimer) is deliberately out of phase
84 | // with the Y curve, which is what yields the "look left, look up, look
85 | // right, look down" effect. Second of all, the effect feels less bouncy
86 | // and more organic if the angles are in proportion to the aspect ratio
87 | // of the view being animated.
88 |
89 | transform3d = CATransform3DRotate(transform3d, yAngle * timer.elapsedTimeY, 1, 0, 0)
90 | transform3d = CATransform3DRotate(transform3d, xAngle * timer.elapsedTimeX, 0, 1, 0)
91 |
92 | // This transform makes the effect feel more natural by applying a bit
93 | // horizontal and vertical translation in the direction that the view is
94 | // facing, the way a human face moves when its head turns, or like a
95 | // flower following the sun.
96 |
97 | transform3d = CATransform3DTranslate(transform3d, xShift * timer.elapsedTimeX, yShift * timer.elapsedTimeY, 0)
98 |
99 | // These next two lines correct for SwiftUI's rather unfortunate choice
100 | // to use (0,0) as the anchor point for projection transforms. The only
101 | // other alternative is to introspect the UIKit hierarchy and modify a
102 | // layer's anchor point, which would be.........bad.
103 |
104 | transform3d = CATransform3DTranslate(transform3d, -width/2, -height/2, 0)
105 | let affineTransform = ProjectionTransform(CGAffineTransform(translationX: width/2, y: height/2))
106 |
107 | // Voila.
108 |
109 | return ProjectionTransform(transform3d).concatenating(affineTransform)
110 | }
111 |
112 | private class RotationTimer: ObservableObject {
113 |
114 | var elapsedTimeX: CGFloat {
115 | sin(2 * .pi * (absoluteTime + 0.25)) // <---- 25% out-of-phase with the Y time
116 | }
117 |
118 | var elapsedTimeY: CGFloat {
119 | sin(2 * .pi * absoluteTime)
120 | }
121 |
122 | var iterationsPerSecond: CFTimeInterval = 1
123 |
124 | @Published private var absoluteTime: CGFloat = 0
125 |
126 | private let link = DisplayLink()
127 |
128 | deinit {
129 | stop()
130 | }
131 |
132 | func start() {
133 | link.start { [weak self] framesPerSecond in
134 | guard let self = self else { return }
135 | self.absoluteTime -= 1.0 / (framesPerSecond / self.iterationsPerSecond)
136 | }
137 | }
138 |
139 | func stop() {
140 | link.stop()
141 | }
142 | }
143 |
144 | }
145 |
--------------------------------------------------------------------------------
/Sources/AntsInMyPants/ContentSizeObserver.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | public struct ContentSizeObserver: View {
4 | @Binding public var size: CGSize?
5 |
6 | public var body: some View {
7 | GeometryReader { proxy in
8 | Color.clear.onAppear {
9 | update(proxy.size)
10 | }
11 | }
12 | }
13 |
14 | private func update(_ newSize: CGSize) {
15 | guard newSize != size else { return }
16 | size = newSize
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Sources/AntsInMyPants/DisplayLink.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | public class DisplayLink: ObservableObject {
4 | private var tickHandler: (_ framesPerSecond: CFTimeInterval) -> Void = {_ in}
5 | private lazy var link = CADisplayLink(target: self, selector: #selector(tick))
6 |
7 | deinit {
8 | stop()
9 | }
10 |
11 | public func start(tickHandler: @escaping (_ framesPerSecond: CFTimeInterval) -> Void) {
12 | self.tickHandler = tickHandler
13 | link.add(to: .main, forMode: .common)
14 | }
15 |
16 | public func stop() {
17 | link.invalidate()
18 | }
19 |
20 | @objc private func tick() {
21 | let actualFramesPerSecond = 1 / (link.targetTimestamp - link.timestamp)
22 | tickHandler(actualFramesPerSecond)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Sources/AntsInMyPants/Radians.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | typealias Radians = CGFloat
4 |
5 | extension Int {
6 |
7 | var radians: CGFloat {
8 | return CGFloat(self).radians
9 | }
10 |
11 | var radiansDouble: Double {
12 | return Double(self) * .pi / 180
13 | }
14 |
15 | }
16 |
17 | extension CGFloat {
18 |
19 | var radians: CGFloat {
20 | return self * .pi / 180
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/tilt.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaredsinclair/antsinmypants/d736a5d569bacc143f0f08eea8edc84e83e37e3e/tilt.gif
--------------------------------------------------------------------------------