Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
Fix CFResources.bundle cannot be loaded when using Cocoapods
  • Loading branch information
JT501 committed Oct 27, 2017
1 parent 5d10978 commit 8c9a5fe
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 21 deletions.
4 changes: 2 additions & 2 deletions CFNotify.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.platform = :ios, "9.0"
s.source = { :git => "https://github.com/hallelujahbaby/CFNotify.git", :tag => "0.9.0" }
s.source_files = "CFNotify", "CFNotify/**/*.{swift,h}"
s.resources = "CFResources/**/*.png"
s.frameworks = 'UIKit'
s.resource_bundles = {"CFResources" =>["CFResources/**/*.png"]}
s.frameworks = "UIKit"
s.requires_arc = true
end
40 changes: 24 additions & 16 deletions CFNotify/CFNotifyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,25 @@ extension CFNotifyView {
}

static func setClassicThemeFor(view: ClassicView, theme: Theme) {
let frameworkBundle = Bundle(for: CFNotifyView.self)
let bundleURL = frameworkBundle.resourceURL?.appendingPathComponent("CFResources.bundle")
let resourceBundle = Bundle(url: bundleURL!)

switch theme {
case .Success(let style):
switch style {
case .Light:
view.backgroundColor = UIColor(red: 65.0/256.0, green: 131.0/256.0, blue: 215.0/256.0, alpha: 1.0)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_success")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_success", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
view.imageView.tintColor = UIColor.white
case .Dark:
view.backgroundColor = UIColor(red: 31.0/256.0, green: 58.0/256.0, blue: 147.0/256.0, alpha: 1.0)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_success_dark")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_success_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
view.imageView.tintColor = UIColor.white
}
Expand All @@ -166,14 +170,14 @@ extension CFNotifyView {
view.backgroundColor = UIColor(red: 231.0/256.0, green: 76.0/256.0, blue: 60.0/256.0, alpha: 1.0)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_fail")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_fail", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
view.imageView.tintColor = UIColor.white
case .Dark:
view.backgroundColor = UIColor(red: 185.0/256.0, green: 29.0/256.0, blue: 71.0/256.0, alpha: 1.0)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_fail_dark")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_fail_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
view.imageView.tintColor = UIColor.white
}
Expand All @@ -183,14 +187,14 @@ extension CFNotifyView {
view.backgroundColor = UIColor(red: 191.0/256.0, green: 191.0/256.0, blue: 191.0/256.0, alpha: 1.0)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_info")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_info", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
view.imageView.tintColor = UIColor.white
case .Dark:
view.backgroundColor = UIColor(red: 29.0/256.0, green: 29.0/256.0, blue: 29.0/256.0, alpha: 1.0)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_info_dark")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_info_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
view.imageView.tintColor = UIColor.white
}
Expand All @@ -200,35 +204,39 @@ extension CFNotifyView {
view.backgroundColor = UIColor(red: 245.0/256.0, green: 171.0/256.0, blue: 53.0/256.0, alpha: 1.0)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_warning")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_warning", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
view.imageView.tintColor = UIColor.white
case .Dark:
view.backgroundColor = UIColor(red: 218.0/256.0, green: 83.0/256.0, blue: 44.0/256.0, alpha: 1.0)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_warning_dark")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_warning_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
view.imageView.tintColor = UIColor.white
}
}
}

static func setCyberThemeFor(view: CyberView, theme: Theme) {
let frameworkBundle = Bundle(for: CFNotifyView.self)
let bundleURL = frameworkBundle.resourceURL?.appendingPathComponent("CFResources.bundle")
let resourceBundle = Bundle(url: bundleURL!)

switch theme {
case .Success(let style):
switch style {
case .Light:
view.backgroundColor = UIColor(red: 65.0/256.0, green: 131.0/256.0, blue: 215.0/256.0, alpha: 0.5)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_success")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_success", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
case .Dark:
view.backgroundColor = UIColor(red: 31.0/256.0, green: 58.0/256.0, blue: 147.0/256.0, alpha: 0.5)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_success_dark")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_success_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
}
case .Fail(let style):
Expand All @@ -237,13 +245,13 @@ extension CFNotifyView {
view.backgroundColor = UIColor(red: 231.0/256.0, green: 76.0/256.0, blue: 60.0/256.0, alpha: 0.5)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_fail")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_fail", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
case .Dark:
view.backgroundColor = UIColor(red: 185.0/256.0, green: 29.0/256.0, blue: 71.0/256.0, alpha: 0.5)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_fail_dark")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_fail_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
}
case .Info(let style):
Expand All @@ -252,13 +260,13 @@ extension CFNotifyView {
view.backgroundColor = UIColor(red: 191.0/256.0, green: 191.0/256.0, blue: 191.0/256.0, alpha: 0.5)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_info")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_info", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
case .Dark:
view.backgroundColor = UIColor(red: 29.0/256.0, green: 29.0/256.0, blue: 29.0/256.0, alpha: 0.5)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_info_dark")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_info_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
}
case .Warning(let style):
Expand All @@ -267,13 +275,13 @@ extension CFNotifyView {
view.backgroundColor = UIColor(red: 245.0/256.0, green: 171.0/256.0, blue: 53.0/256.0, alpha: 0.5)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_warning")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_warning", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
case .Dark:
view.backgroundColor = UIColor(red: 218.0/256.0, green: 83.0/256.0, blue: 44.0/256.0, alpha: 0.5)
view.titleTextColor = UIColor.white
view.bodyTextColor = UIColor.white
let image = UIImage(named: "CFResources.bundle/icon_warning_dark")?.withRenderingMode(.alwaysTemplate)
let image = UIImage(named: "icon_warning_dark", in: resourceBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
view.imageView.image = image
view.imageView.tintColor = UIColor.white
}
Expand Down
39 changes: 36 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
# CFDraggableMessage
Framework to Create Draggable Message View
CFNotify
===============
[![GitHub issues](https://img.shields.io/github/issues/hallelujahbaby/CFNotify.svg?style=flat-square)](https://github.com/hallelujahbaby/CFNotify/issues)
[![Swift](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat-square)](https://developer.apple.com/swift/)
[![GitHub forks](https://img.shields.io/github/forks/hallelujahbaby/CFNotify.svg?style=flat-square)](https://github.com/hallelujahbaby/CFNotify/network)
[![GitHub stars](https://img.shields.io/github/stars/hallelujahbaby/CFNotify.svg?style=flat-square)](https://github.com/hallelujahbaby/CFNotify/stargazers)
[![GitHub license](https://img.shields.io/github/license/hallelujahbaby/CFNotify.svg?style=flat-square)](https://github.com/hallelujahbaby/CFNotify/blob/master/LICENSE)

Still in Development Stage, not yet finish
## Requirements
* Swift 4.0+
* Xcode 9
* iOS 9.0+

Installation
------------------
* #### [Carthage](https://github.com/Carthage/Carthage) (_Recommended_)
Add the following lines into [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile)

````bash
#CFNotify
github "hallelujahbaby/CFNotify"
````

Run `carthage update` and then add **CFNotify.framework** and **CFResources.bundle** into your project

* #### [Cocoapods](https://cocoapods.org/)
Add the following lines into Podfile

````ruby
pod "CFNotify"
````

License
-------------------
***CFNotify*** is released under an [MIT License][mitLink]. See [LICENSE](./LICENSE.md) for details.

[mitLink]:http://opensource.org/licenses/MIT

0 comments on commit 8c9a5fe

Please sign in to comment.