Skip to content

Commit bc049cb

Browse files
committed
[master] - Release v2.5.1
1 parent 3eff4e2 commit bc049cb

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

Example/NotificationBanner/ExampleViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ extension ExampleViewController: ExampleViewDelegate {
256256
default:
257257
let banner = FloatingNotificationBanner(customView: NorthCarolinaBannerView())
258258
banner.delegate = self
259+
banner.transparency = 0.75
259260
banner.show(queuePosition: selectedQueuePosition(),
260261
bannerPosition: selectedBannerPosition(),
261262
cornerRadius: 10,

NotificationBanner/Classes/BaseNotificationBanner.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public protocol NotificationBannerDelegate: class {
2929
}
3030

3131
@objcMembers
32-
public class BaseNotificationBanner: UIView {
32+
open class BaseNotificationBanner: UIView {
3333

3434
/// Notification that will be posted when a notification banner will appear
3535
public static let BannerWillAppear: Notification.Name = Notification.Name(rawValue: "NotificationBannerWillAppear")
@@ -88,8 +88,12 @@ public class BaseNotificationBanner: UIView {
8888
/// The transparency of the background of the notification banner
8989
public var transparency: CGFloat = 1.0 {
9090
didSet {
91-
let color = backgroundColor
92-
self.backgroundColor = color
91+
if let customView = customView {
92+
customView.backgroundColor = customView.backgroundColor?.withAlphaComponent(transparency)
93+
} else {
94+
let color = backgroundColor
95+
self.backgroundColor = color
96+
}
9397
}
9498
}
9599

@@ -123,6 +127,9 @@ public class BaseNotificationBanner: UIView {
123127
/// A view that helps the spring animation look nice when the banner appears
124128
internal var spacerView: UIView!
125129

130+
// The custom view inside the notification banner
131+
internal var customView: UIView?
132+
126133
/// The default offset for spacerView top or bottom
127134
internal var spacerViewDefaultOffset: CGFloat = 10.0
128135

@@ -161,10 +168,11 @@ public class BaseNotificationBanner: UIView {
161168
return [BaseNotificationBanner.BannerObjectKey: self]
162169
}
163170

164-
public override var backgroundColor: UIColor? {
171+
open override var backgroundColor: UIColor? {
165172
get {
166173
return contentView.backgroundColor
167174
} set {
175+
guard style != .customView else { return }
168176
let color = newValue?.withAlphaComponent(transparency)
169177
contentView.backgroundColor = color
170178
spacerView.backgroundColor = color
@@ -192,7 +200,7 @@ public class BaseNotificationBanner: UIView {
192200
addGestureRecognizer(swipeUpGesture)
193201
}
194202

195-
required init?(coder aDecoder: NSCoder) {
203+
required public init?(coder aDecoder: NSCoder) {
196204
fatalError("init(coder:) has not been implemented")
197205
}
198206

NotificationBanner/Classes/FloatingNotificationBanner.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import UIKit
2020
import SnapKit
2121

22-
public class FloatingNotificationBanner: GrowingNotificationBanner {
22+
open class FloatingNotificationBanner: GrowingNotificationBanner {
2323

2424
public init(title: String? = nil,
2525
subtitle: String? = nil,
@@ -66,6 +66,8 @@ public class FloatingNotificationBanner: GrowingNotificationBanner {
6666

6767
public init(customView: UIView) {
6868
super.init(style: .customView)
69+
self.customView = customView
70+
6971
contentView.addSubview(customView)
7072
customView.snp.makeConstraints { (make) in
7173
make.edges.equalTo(contentView)

NotificationBanner/Classes/GrowingNotificationBanner.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import UIKit
2020
import SnapKit
2121

22-
public class GrowingNotificationBanner: BaseNotificationBanner {
22+
open class GrowingNotificationBanner: BaseNotificationBanner {
2323

2424
public enum IconPosition {
2525
case top

NotificationBanner/Classes/NotificationBanner.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import SnapKit
2222
import MarqueeLabel
2323

2424
@objcMembers
25-
public class NotificationBanner: BaseNotificationBanner {
25+
open class NotificationBanner: BaseNotificationBanner {
2626

2727
/// The bottom most label of the notification if a subtitle is provided
2828
public private(set) var subtitleLabel: MarqueeLabel?
@@ -157,6 +157,8 @@ public class NotificationBanner: BaseNotificationBanner {
157157

158158
public init(customView: UIView) {
159159
super.init(style: .customView)
160+
self.customView = customView
161+
160162
contentView.addSubview(customView)
161163
customView.snp.makeConstraints { (make) in
162164
make.edges.equalTo(contentView)

NotificationBanner/Classes/StatusBarNotificationBanner.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import UIKit
2121
import MarqueeLabel
2222

2323
@objcMembers
24-
public class StatusBarNotificationBanner: BaseNotificationBanner {
24+
open class StatusBarNotificationBanner: BaseNotificationBanner {
2525

2626
public override var bannerHeight: CGFloat {
2727
get {
@@ -74,6 +74,8 @@ public class StatusBarNotificationBanner: BaseNotificationBanner {
7474

7575
public init(customView: UIView) {
7676
super.init(style: .customView)
77+
self.customView = customView
78+
7779
contentView.addSubview(customView)
7880
customView.snp.makeConstraints { make in
7981
make.edges.equalTo(contentView)

NotificationBannerSwift.podspec

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

22
Pod::Spec.new do |s|
33
s.name = 'NotificationBannerSwift'
4-
s.version = '2.5.0'
4+
s.version = '2.5.1'
55
s.summary = 'The easiest way to display in app notification banners in iOS.'
66

77
s.description = <<-DESC

0 commit comments

Comments
 (0)