Skip to content

Commit

Permalink
Add blur on container
Browse files Browse the repository at this point in the history
  • Loading branch information
pboulch committed Feb 2, 2023
1 parent 2397f22 commit 1af2bb7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ final class RootViewController: UIViewController {
let viewController = ResizeViewController(initialHeight: 300)
presentBottomSheetInsideNavigationController(
viewController: viewController,
configuration: .default
configuration: BottomSheetConfiguration(
cornerRadius: 10,
pullBarConfiguration: .visible(.init(height: 50)),
shadowConfiguration: .init(backgroundColor: UIColor.black.withAlphaComponent(0.6), blur: .light)
)
)
}
}
4 changes: 3 additions & 1 deletion Sources/BottomSheet/Core/BottomSheetConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public struct BottomSheetConfiguration {

public struct ShadowConfiguration {
public let backgroundColor: UIColor
public let blur: UIBlurEffect.Style?

public init(backgroundColor: UIColor) {
public init(backgroundColor: UIColor, blur: UIBlurEffect.Style? = nil) {
self.backgroundColor = backgroundColor
self.blur = blur
}

public static let `default` = ShadowConfiguration(backgroundColor: UIColor.black.withAlphaComponent(0.6))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ public final class BottomSheetPresentationController: UIPresentationController {
}

private func addShadow(containerView: UIView) {
let shadingView = UIView()
var shadingView = UIView()
if let blur = configuration.shadowConfiguration.blur {
shadingView = UIVisualEffectView.init(effect: UIBlurEffect.init(style: blur))
}

shadingView.backgroundColor = configuration.shadowConfiguration.backgroundColor
containerView.addSubview(shadingView)
shadingView.frame = containerView.bounds
Expand Down

0 comments on commit 1af2bb7

Please sign in to comment.