Skip to content

Commit 8c9a5fe

Browse files
committed
Update README
Fix CFResources.bundle cannot be loaded when using Cocoapods
1 parent 5d10978 commit 8c9a5fe

File tree

3 files changed

+62
-21
lines changed

3 files changed

+62
-21
lines changed

CFNotify.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
1212
s.platform = :ios, "9.0"
1313
s.source = { :git => "https://github.com/hallelujahbaby/CFNotify.git", :tag => "0.9.0" }
1414
s.source_files = "CFNotify", "CFNotify/**/*.{swift,h}"
15-
s.resources = "CFResources/**/*.png"
16-
s.frameworks = 'UIKit'
15+
s.resource_bundles = {"CFResources" =>["CFResources/**/*.png"]}
16+
s.frameworks = "UIKit"
1717
s.requires_arc = true
1818
end

CFNotify/CFNotifyView.swift

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,25 @@ extension CFNotifyView {
142142
}
143143

144144
static func setClassicThemeFor(view: ClassicView, theme: Theme) {
145+
let frameworkBundle = Bundle(for: CFNotifyView.self)
146+
let bundleURL = frameworkBundle.resourceURL?.appendingPathComponent("CFResources.bundle")
147+
let resourceBundle = Bundle(url: bundleURL!)
148+
145149
switch theme {
146150
case .Success(let style):
147151
switch style {
148152
case .Light:
149153
view.backgroundColor = UIColor(red: 65.0/256.0, green: 131.0/256.0, blue: 215.0/256.0, alpha: 1.0)
150154
view.titleTextColor = UIColor.white
151155
view.bodyTextColor = UIColor.white
152-
let image = UIImage(named: "CFResources.bundle/icon_success")?.withRenderingMode(.alwaysTemplate)
156+
let image = UIImage(named: "icon_success", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
153157
view.imageView.image = image
154158
view.imageView.tintColor = UIColor.white
155159
case .Dark:
156160
view.backgroundColor = UIColor(red: 31.0/256.0, green: 58.0/256.0, blue: 147.0/256.0, alpha: 1.0)
157161
view.titleTextColor = UIColor.white
158162
view.bodyTextColor = UIColor.white
159-
let image = UIImage(named: "CFResources.bundle/icon_success_dark")?.withRenderingMode(.alwaysTemplate)
163+
let image = UIImage(named: "icon_success_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
160164
view.imageView.image = image
161165
view.imageView.tintColor = UIColor.white
162166
}
@@ -166,14 +170,14 @@ extension CFNotifyView {
166170
view.backgroundColor = UIColor(red: 231.0/256.0, green: 76.0/256.0, blue: 60.0/256.0, alpha: 1.0)
167171
view.titleTextColor = UIColor.white
168172
view.bodyTextColor = UIColor.white
169-
let image = UIImage(named: "CFResources.bundle/icon_fail")?.withRenderingMode(.alwaysTemplate)
173+
let image = UIImage(named: "icon_fail", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
170174
view.imageView.image = image
171175
view.imageView.tintColor = UIColor.white
172176
case .Dark:
173177
view.backgroundColor = UIColor(red: 185.0/256.0, green: 29.0/256.0, blue: 71.0/256.0, alpha: 1.0)
174178
view.titleTextColor = UIColor.white
175179
view.bodyTextColor = UIColor.white
176-
let image = UIImage(named: "CFResources.bundle/icon_fail_dark")?.withRenderingMode(.alwaysTemplate)
180+
let image = UIImage(named: "icon_fail_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
177181
view.imageView.image = image
178182
view.imageView.tintColor = UIColor.white
179183
}
@@ -183,14 +187,14 @@ extension CFNotifyView {
183187
view.backgroundColor = UIColor(red: 191.0/256.0, green: 191.0/256.0, blue: 191.0/256.0, alpha: 1.0)
184188
view.titleTextColor = UIColor.white
185189
view.bodyTextColor = UIColor.white
186-
let image = UIImage(named: "CFResources.bundle/icon_info")?.withRenderingMode(.alwaysTemplate)
190+
let image = UIImage(named: "icon_info", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
187191
view.imageView.image = image
188192
view.imageView.tintColor = UIColor.white
189193
case .Dark:
190194
view.backgroundColor = UIColor(red: 29.0/256.0, green: 29.0/256.0, blue: 29.0/256.0, alpha: 1.0)
191195
view.titleTextColor = UIColor.white
192196
view.bodyTextColor = UIColor.white
193-
let image = UIImage(named: "CFResources.bundle/icon_info_dark")?.withRenderingMode(.alwaysTemplate)
197+
let image = UIImage(named: "icon_info_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
194198
view.imageView.image = image
195199
view.imageView.tintColor = UIColor.white
196200
}
@@ -200,35 +204,39 @@ extension CFNotifyView {
200204
view.backgroundColor = UIColor(red: 245.0/256.0, green: 171.0/256.0, blue: 53.0/256.0, alpha: 1.0)
201205
view.titleTextColor = UIColor.white
202206
view.bodyTextColor = UIColor.white
203-
let image = UIImage(named: "CFResources.bundle/icon_warning")?.withRenderingMode(.alwaysTemplate)
207+
let image = UIImage(named: "icon_warning", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
204208
view.imageView.image = image
205209
view.imageView.tintColor = UIColor.white
206210
case .Dark:
207211
view.backgroundColor = UIColor(red: 218.0/256.0, green: 83.0/256.0, blue: 44.0/256.0, alpha: 1.0)
208212
view.titleTextColor = UIColor.white
209213
view.bodyTextColor = UIColor.white
210-
let image = UIImage(named: "CFResources.bundle/icon_warning_dark")?.withRenderingMode(.alwaysTemplate)
214+
let image = UIImage(named: "icon_warning_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
211215
view.imageView.image = image
212216
view.imageView.tintColor = UIColor.white
213217
}
214218
}
215219
}
216220

217221
static func setCyberThemeFor(view: CyberView, theme: Theme) {
222+
let frameworkBundle = Bundle(for: CFNotifyView.self)
223+
let bundleURL = frameworkBundle.resourceURL?.appendingPathComponent("CFResources.bundle")
224+
let resourceBundle = Bundle(url: bundleURL!)
225+
218226
switch theme {
219227
case .Success(let style):
220228
switch style {
221229
case .Light:
222230
view.backgroundColor = UIColor(red: 65.0/256.0, green: 131.0/256.0, blue: 215.0/256.0, alpha: 0.5)
223231
view.titleTextColor = UIColor.white
224232
view.bodyTextColor = UIColor.white
225-
let image = UIImage(named: "CFResources.bundle/icon_success")?.withRenderingMode(.alwaysTemplate)
233+
let image = UIImage(named: "icon_success", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
226234
view.imageView.image = image
227235
case .Dark:
228236
view.backgroundColor = UIColor(red: 31.0/256.0, green: 58.0/256.0, blue: 147.0/256.0, alpha: 0.5)
229237
view.titleTextColor = UIColor.white
230238
view.bodyTextColor = UIColor.white
231-
let image = UIImage(named: "CFResources.bundle/icon_success_dark")?.withRenderingMode(.alwaysTemplate)
239+
let image = UIImage(named: "icon_success_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
232240
view.imageView.image = image
233241
}
234242
case .Fail(let style):
@@ -237,13 +245,13 @@ extension CFNotifyView {
237245
view.backgroundColor = UIColor(red: 231.0/256.0, green: 76.0/256.0, blue: 60.0/256.0, alpha: 0.5)
238246
view.titleTextColor = UIColor.white
239247
view.bodyTextColor = UIColor.white
240-
let image = UIImage(named: "CFResources.bundle/icon_fail")?.withRenderingMode(.alwaysTemplate)
248+
let image = UIImage(named: "icon_fail", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
241249
view.imageView.image = image
242250
case .Dark:
243251
view.backgroundColor = UIColor(red: 185.0/256.0, green: 29.0/256.0, blue: 71.0/256.0, alpha: 0.5)
244252
view.titleTextColor = UIColor.white
245253
view.bodyTextColor = UIColor.white
246-
let image = UIImage(named: "CFResources.bundle/icon_fail_dark")?.withRenderingMode(.alwaysTemplate)
254+
let image = UIImage(named: "icon_fail_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
247255
view.imageView.image = image
248256
}
249257
case .Info(let style):
@@ -252,13 +260,13 @@ extension CFNotifyView {
252260
view.backgroundColor = UIColor(red: 191.0/256.0, green: 191.0/256.0, blue: 191.0/256.0, alpha: 0.5)
253261
view.titleTextColor = UIColor.white
254262
view.bodyTextColor = UIColor.white
255-
let image = UIImage(named: "CFResources.bundle/icon_info")?.withRenderingMode(.alwaysTemplate)
263+
let image = UIImage(named: "icon_info", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
256264
view.imageView.image = image
257265
case .Dark:
258266
view.backgroundColor = UIColor(red: 29.0/256.0, green: 29.0/256.0, blue: 29.0/256.0, alpha: 0.5)
259267
view.titleTextColor = UIColor.white
260268
view.bodyTextColor = UIColor.white
261-
let image = UIImage(named: "CFResources.bundle/icon_info_dark")?.withRenderingMode(.alwaysTemplate)
269+
let image = UIImage(named: "icon_info_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
262270
view.imageView.image = image
263271
}
264272
case .Warning(let style):
@@ -267,13 +275,13 @@ extension CFNotifyView {
267275
view.backgroundColor = UIColor(red: 245.0/256.0, green: 171.0/256.0, blue: 53.0/256.0, alpha: 0.5)
268276
view.titleTextColor = UIColor.white
269277
view.bodyTextColor = UIColor.white
270-
let image = UIImage(named: "CFResources.bundle/icon_warning")?.withRenderingMode(.alwaysTemplate)
278+
let image = UIImage(named: "icon_warning", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
271279
view.imageView.image = image
272280
case .Dark:
273281
view.backgroundColor = UIColor(red: 218.0/256.0, green: 83.0/256.0, blue: 44.0/256.0, alpha: 0.5)
274282
view.titleTextColor = UIColor.white
275283
view.bodyTextColor = UIColor.white
276-
let image = UIImage(named: "CFResources.bundle/icon_warning_dark")?.withRenderingMode(.alwaysTemplate)
284+
let image = UIImage(named: "icon_warning_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
277285
view.imageView.image = image
278286
view.imageView.tintColor = UIColor.white
279287
}

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
1-
# CFDraggableMessage
2-
Framework to Create Draggable Message View
1+
CFNotify
2+
===============
3+
[![GitHub issues](https://img.shields.io/github/issues/hallelujahbaby/CFNotify.svg?style=flat-square)](https://github.com/hallelujahbaby/CFNotify/issues)
4+
[![Swift](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat-square)](https://developer.apple.com/swift/)
5+
[![GitHub forks](https://img.shields.io/github/forks/hallelujahbaby/CFNotify.svg?style=flat-square)](https://github.com/hallelujahbaby/CFNotify/network)
6+
[![GitHub stars](https://img.shields.io/github/stars/hallelujahbaby/CFNotify.svg?style=flat-square)](https://github.com/hallelujahbaby/CFNotify/stargazers)
7+
[![GitHub license](https://img.shields.io/github/license/hallelujahbaby/CFNotify.svg?style=flat-square)](https://github.com/hallelujahbaby/CFNotify/blob/master/LICENSE)
38

4-
Still in Development Stage, not yet finish
9+
## Requirements
10+
* Swift 4.0+
11+
* Xcode 9
12+
* iOS 9.0+
13+
14+
Installation
15+
------------------
16+
* #### [Carthage](https://github.com/Carthage/Carthage) (_Recommended_)
17+
Add the following lines into [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile)
18+
19+
````bash
20+
#CFNotify
21+
github "hallelujahbaby/CFNotify"
22+
````
23+
24+
Run `carthage update` and then add **CFNotify.framework** and **CFResources.bundle** into your project
25+
26+
* #### [Cocoapods](https://cocoapods.org/)
27+
Add the following lines into Podfile
28+
29+
````ruby
30+
pod "CFNotify"
31+
````
32+
33+
License
34+
-------------------
35+
***CFNotify*** is released under an [MIT License][mitLink]. See [LICENSE](./LICENSE.md) for details.
36+
37+
[mitLink]:http://opensource.org/licenses/MIT

0 commit comments

Comments
 (0)