Skip to content

Commit 4a2c1e0

Browse files
committed
trail 2
1 parent 13a2e8a commit 4a2c1e0

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

MotionToastView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'MotionToastView'
11-
s.version = '0.1.5'
11+
s.version = '0.1.6'
1212
s.summary = 'A Beautiful Toast Library for iOS Swift'
1313

1414
# This description is used to generate tags and improve search results.

Source/MotionToastStyles/MTPale.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,43 @@ class MTPale: UIView {
5151
switch toastType {
5252
case .success:
5353
headLabel.text = "Success"
54-
circleImg.image = UIImage(named: "success_icon_white", in: bundle, compatibleWith: nil)!
54+
circleImg.image = loadImage(name: "success_icon_white")
5555
sideBarView.backgroundColor = UIColor(hex: "6FCF97")
5656
circleView.backgroundColor = UIColor(hex: "6FCF97")
5757
toastView.backgroundColor = UIColor(named: "alpha_green_dark", in: bundle, compatibleWith: nil)!
5858
break
5959
case .error:
6060
headLabel.text = "Error"
61-
circleImg.image = UIImage(named: "error_icon_white", in: bundle, compatibleWith: nil)!
61+
circleImg.image = loadImage(name: "error_icon_white")
6262
sideBarView.backgroundColor = UIColor(hex: "EB5757")
6363
circleView.backgroundColor = UIColor(hex: "EB5757")
6464
toastView.backgroundColor = UIColor(named: "alpha_red_dark", in: bundle, compatibleWith: nil)!
6565
break
6666
case .warning:
6767
headLabel.text = "Warning"
68-
circleImg.image = UIImage(named: "warning_icon_white", in: bundle, compatibleWith: nil)!
68+
circleImg.image = loadImage(name: "warning_icon_white")
6969
sideBarView.backgroundColor = UIColor(hex: "F2C94C")
7070
circleView.backgroundColor = UIColor(hex: "F2C94C")
7171
toastView.backgroundColor = UIColor(named: "alpha_yellow_dark", in: bundle, compatibleWith: nil)!
7272
break
7373
case .info:
7474
headLabel.text = "Info"
75-
circleImg.image = UIImage(named: "info_icon_white", in: bundle, compatibleWith: nil)!
75+
circleImg.image = loadImage(name: "info_icon_white")
7676
sideBarView.backgroundColor = UIColor(hex: "2F80ED")
7777
circleView.backgroundColor = UIColor(hex: "2F80ED")
7878
toastView.backgroundColor = UIColor(named: "alpha_blue_dark", in: bundle, compatibleWith: nil)!
7979
break
8080
}
8181
}
82+
83+
func loadImage(name: String) -> UIImage? {
84+
let podBundle = Bundle(for: MTPale.self)
85+
if let url = podBundle.url(forResource: "MotionToastView", withExtension: "bundle") {
86+
let bundle = Bundle(url: url)
87+
return UIImage(named: name, in: bundle, compatibleWith: nil)
88+
}
89+
print("MotionToastView")
90+
return nil
91+
}
92+
8293
}

Source/MotionToastStyles/MTVibrant.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,37 @@ class MTVibrant: UIView {
4949
case .success:
5050
headLabel.text = "Success"
5151
headLabel.textColor = UIColor(named: "white_green", in: bundle, compatibleWith: nil)!
52-
circleImg.image = UIImage(named: "success_icon", in: bundle, compatibleWith: nil)!
52+
circleImg.image = loadImage(name: "success_icon")
5353
toastView.backgroundColor = UIColor(named: "green_dark", in: bundle, compatibleWith: nil)!
5454
break
5555
case .error:
5656
headLabel.text = "Error"
5757
headLabel.textColor = UIColor(named: "white_red", in: bundle, compatibleWith: nil)!
58-
circleImg.image = UIImage(named: "error_icon", in: bundle, compatibleWith: nil)!
58+
circleImg.image = loadImage(name: "error_icon")
5959
toastView.backgroundColor = UIColor(named: "red_dark", in: bundle, compatibleWith: nil)!
6060
break
6161
case .warning:
6262
headLabel.text = "Warning"
6363
headLabel.textColor = UIColor(named: "white_yellow", in: bundle, compatibleWith: nil)!
64-
circleImg.image = UIImage(named: "warning_icon", in: bundle, compatibleWith: nil)!
64+
circleImg.image = loadImage(name: "warning_icon")
6565
toastView.backgroundColor = UIColor(named: "yellow_dark", in: bundle, compatibleWith: nil)!
6666
break
6767
case .info:
6868
headLabel.text = "Info"
6969
headLabel.textColor = UIColor(named: "white_blue", in: bundle, compatibleWith: nil)!
70-
circleImg.image = UIImage(named: "info_icon", in: bundle, compatibleWith: nil)!
70+
circleImg.image = loadImage(name: "info_icon")
7171
toastView.backgroundColor = UIColor(named: "blue_dark", in: bundle, compatibleWith: nil)!
7272
break
7373
}
7474
}
75+
76+
func loadImage(name: String) -> UIImage? {
77+
let podBundle = Bundle(for: MTVibrant.self)
78+
if let url = podBundle.url(forResource: "MotionToastView", withExtension: "bundle") {
79+
let bundle = Bundle(url: url)
80+
return UIImage(named: name, in: bundle, compatibleWith: nil)
81+
}
82+
print("MotionToastView")
83+
return nil
84+
}
7585
}

0 commit comments

Comments
 (0)