FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
archive-example/ArchiveExampleiOS/ViewController.swift at master · kitecomp/archive-example · GitHub
kitecomp
/
archive-example
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
4
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
archive-example
/
ArchiveExampleiOS
/
ViewController.swift
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (33 loc) · 1.15 KB
Breadcrumbs
archive-example
/
ArchiveExampleiOS
/
ViewController.swift
Copy path
File metadata and controls
42 lines (33 loc) · 1.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//
// ViewController.swift
// ArchiveExampleiOS
//
import
UIKit
class
ViewController
:
UIViewController
{
override
func
viewDidLoad
(
)
{
super
.
viewDidLoad
(
)
// Path to the .caar file
//
guard
let
emojiURL
=
Bundle
.
main
.
url
(
forResource
:
"
Emoji
"
,
withExtension
:
"
caar
"
)
else
{
return
}
// Read the .caar file into memory
//
guard
let
emojiData
=
try
?
Data
(
contentsOf
:
emojiURL
)
else
{
return
}
// Unarchive the NSKeyedArchive as a Dictionary
//
guard
let
rootObject
=
(
try
?
NSKeyedUnarchiver
.
unarchiveTopLevelObjectWithData
(
emojiData
)
)
as?
[
String
:
Any
]
else
{
return
}
// Pull out the 'rootLayer' object containing the archived CALayer
//
guard
let
rootLayer
=
rootObject
[
"
rootLayer
"
]
as?
CALayer
else
{
return
}
// Un-flip the layer for iOS's coordinate system
//
rootLayer
.
isGeometryFlipped
=
false
// Start the rootLayer's timeline at the current time
//
rootLayer
.
beginTime
=
CACurrentMediaTime
(
)
// Add it to the layer hierarchy
//
self
.
view
.
layer
.
addSublayer
(
rootLayer
)
}
}
Back
|
FazBrowse Home
|
New Git URL