Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to turn off blur effect by using nil. #321

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Source/AlertVisualStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ open class AlertVisualStyle: NSObject {
}
}()

var blurEffect: UIBlurEffect {
/// The standard blur effect
@objc
public var blurEffect: UIBlurEffect? = AlertVisualStyle.standardBlurEffect()

/// The style of the alert.
private let alertStyle: AlertControllerStyle

private static func standardBlurEffect() -> UIBlurEffect {
if #available(iOS 13, *) {
return UIBlurEffect(style: .systemMaterial)
} else if #available(iOS 10, *) {
Expand All @@ -143,10 +150,7 @@ open class AlertVisualStyle: NSObject {
return UIBlurEffect(style: .extraLight)
}
}

/// The style of the alert.
private let alertStyle: AlertControllerStyle


@objc
public init(alertStyle: AlertControllerStyle) {
self.alertStyle = alertStyle
Expand Down
2 changes: 1 addition & 1 deletion Source/Views/ActionSheetCancelActionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class ActionSheetCancelActionView: UIView {
}
}

private func addBlurBackground(effect: UIBlurEffect) {
private func addBlurBackground(effect: UIBlurEffect?) {
self.blurBackground.effect = effect
self.blurBackground.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(self.blurBackground)
Expand Down
8 changes: 5 additions & 3 deletions Source/Views/ActionSheetPrimaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,21 @@ final class ActionSheetPrimaryView: UIView {
self.layer.masksToBounds = true
}

private func buildBackgroundBlur(effect: UIVisualEffect) -> UIVisualEffectView {
private func buildBackgroundBlur(effect: UIVisualEffect?) -> UIVisualEffectView {
let backgroundBlur = UIVisualEffectView(effect: effect)
backgroundBlur.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(backgroundBlur)

return backgroundBlur
}

private func buildLabelVibrancy(effect: UIBlurEffect) -> UIVisualEffectView {
private func buildLabelVibrancy(effect: UIBlurEffect?) -> UIVisualEffectView {
let vibrancy = UIVisualEffectView(effect: effect)
vibrancy.translatesAutoresizingMaskIntoConstraints = false
if #available(iOS 13, *) {
vibrancy.effect = UIVibrancyEffect(blurEffect: effect, style: .secondaryLabel)
if let effect = effect {
vibrancy.effect = UIVibrancyEffect(blurEffect: effect, style: .secondaryLabel)
}
}

return vibrancy
Expand Down