Skip to content

Commit a26637b

Browse files
committed
Cutting Image With Completion Handler
1 parent 1c59c36 commit a26637b

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

THTiledImageView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'THTiledImageView'
3-
s.version = '0.2.1'
3+
s.version = '0.2.2'
44
s.summary = 'High Quality Image ScrollView using cropped tiled images.'
55

66
s.description = <<-DESC

THTiledImageView/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>0.2</string>
20+
<string>0.2.2</string>
2121
<key>CFBundleVersion</key>
2222
<string>1</string>
2323
<key>LSRequiresIPhoneOS</key>

THTiledImageView/THTiledImageView/THTiledImageGenerateHelper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ extension FileManager {
2424
}
2525

2626
extension UIImage {
27-
public class func saveTileOf(size: [CGSize], name: String, withExtension: String) {
27+
public class func saveTileOf(size: [CGSize], name: String,
28+
withExtension: String, completion: @escaping (Bool) -> Void ) {
2829

2930
let cachesPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0] as String
3031

@@ -99,8 +100,11 @@ extension UIImage {
99100
}
100101
}
101102
print("\(imageSize.width) image cutting finish")
103+
completion(true)
102104
}
103105
}
106+
} else {
107+
completion(false)
104108
}
105109
}
106110
}

THTiledImageView/ViewController.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class ViewController: UIViewController {
2020
CGSize(width: 512, height: 512), CGSize(width: 256, height: 256),
2121
CGSize(width: 128, height: 128)]
2222

23-
UIImage.saveTileOf(size: tiles, name: "bench", withExtension: "jpg")
23+
UIImage.saveTileOf(size: tiles, name: "bench", withExtension: "jpg") { _ in
24+
25+
}
2426

2527
let imageSize = CGSize(width: 5214, height: 7300)
2628
let thumbnailImageURL = Bundle.main.url(forResource: "smallBench", withExtension: "jpg")!

0 commit comments

Comments
 (0)