Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 837edc6abf | |||
| 20fda3888f | |||
| 4728c6848b | |||
| 70c945c9f5 |
@@ -4,8 +4,18 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import FloatingPanel
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
||||
FloatingPanelSurfaceView.appearance().shadowHidden = false
|
||||
FloatingPanelSurfaceView.appearance().cornerRadius = 6.0
|
||||
// FloatingPanelSurfaceView.appearance().backgroundColor = .lightGray
|
||||
// FloatingPanelBackdropView.appearance().backgroundColor = .red
|
||||
// GrabberHandleView.appearance().barColor = .red
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,10 +123,6 @@ class SampleListViewController: UIViewController {
|
||||
mainPanelVC = FloatingPanelController()
|
||||
mainPanelVC.delegate = self
|
||||
|
||||
// Initialize FloatingPanelController and add the view
|
||||
mainPanelVC.surfaceView.cornerRadius = 6.0
|
||||
mainPanelVC.surfaceView.shadowHidden = false
|
||||
|
||||
// Set a content view controller
|
||||
mainPanelVC.set(contentViewController: contentVC)
|
||||
|
||||
|
||||
@@ -68,10 +68,8 @@ class FloatingPanel: NSObject, UIGestureRecognizerDelegate, UIScrollViewDelegate
|
||||
viewcontroller = vc
|
||||
|
||||
surfaceView = FloatingPanelSurfaceView()
|
||||
surfaceView.backgroundColor = .white
|
||||
|
||||
backdropView = FloatingPanelBackdropView()
|
||||
backdropView.backgroundColor = .black
|
||||
backdropView.alpha = 0.0
|
||||
|
||||
self.layoutAdapter = FloatingPanelLayoutAdapter(surfaceView: surfaceView,
|
||||
|
||||
@@ -6,4 +6,26 @@
|
||||
import UIKit
|
||||
|
||||
/// A view that presents a backdrop interface behind a floating panel.
|
||||
public class FloatingPanelBackdropView: UIView { }
|
||||
public class FloatingPanelBackdropView: UIView {
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setUp()
|
||||
}
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
setUp()
|
||||
}
|
||||
|
||||
private func setUp() {
|
||||
layer.backgroundColor = UIColor.black.cgColor
|
||||
}
|
||||
|
||||
@objc dynamic public override var backgroundColor: UIColor? {
|
||||
get {
|
||||
guard let color = layer.backgroundColor else { return nil }
|
||||
return UIColor(cgColor: color)
|
||||
}
|
||||
set { layer.backgroundColor = newValue?.cgColor }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FloatingPanelSurfaceView: UIView {
|
||||
public let grabberHandle: GrabberHandleView = GrabberHandleView()
|
||||
|
||||
/// Offset of the grabber handle from the top
|
||||
public var grabberTopPadding: CGFloat = 6.0 { didSet {
|
||||
@objc dynamic public var grabberTopPadding: CGFloat = 6.0 { didSet {
|
||||
setNeedsUpdateConstraints()
|
||||
} }
|
||||
|
||||
@@ -25,10 +25,10 @@ public class FloatingPanelSurfaceView: UIView {
|
||||
}
|
||||
|
||||
/// Grabber view width and height
|
||||
public var grabberHandleWidth: CGFloat = 36.0 { didSet {
|
||||
@objc dynamic public var grabberHandleWidth: CGFloat = 36.0 { didSet {
|
||||
setNeedsUpdateConstraints()
|
||||
} }
|
||||
public var grabberHandleHeight: CGFloat = 5.0 { didSet {
|
||||
@objc dynamic public var grabberHandleHeight: CGFloat = 5.0 { didSet {
|
||||
setNeedsUpdateConstraints()
|
||||
} }
|
||||
|
||||
@@ -48,7 +48,7 @@ public class FloatingPanelSurfaceView: UIView {
|
||||
private var color: UIColor? = .white { didSet { setNeedsLayout() } }
|
||||
var bottomOverflow: CGFloat = 0.0 // Must not call setNeedsLayout()
|
||||
|
||||
public override var backgroundColor: UIColor? {
|
||||
@objc dynamic public override var backgroundColor: UIColor? {
|
||||
get { return color }
|
||||
set { color = newValue }
|
||||
}
|
||||
@@ -57,34 +57,34 @@ public class FloatingPanelSurfaceView: UIView {
|
||||
///
|
||||
/// `self.contentView` is masked with the top rounded corners automatically on iOS 11 and later.
|
||||
/// On iOS 10, they are not automatically masked because of a UIVisualEffectView issue. See https://forums.developer.apple.com/thread/50854
|
||||
public var cornerRadius: CGFloat {
|
||||
@objc dynamic public var cornerRadius: CGFloat {
|
||||
set { containerView.layer.cornerRadius = newValue; setNeedsLayout() }
|
||||
get { return containerView.layer.cornerRadius }
|
||||
}
|
||||
|
||||
/// A Boolean indicating whether the surface shadow is displayed.
|
||||
public var shadowHidden: Bool = false { didSet { setNeedsLayout() } }
|
||||
@objc dynamic public var shadowHidden: Bool = false { didSet { setNeedsLayout() } }
|
||||
|
||||
/// The color of the surface shadow.
|
||||
public var shadowColor: UIColor = .black { didSet { setNeedsLayout() } }
|
||||
@objc dynamic public var shadowColor: UIColor = .black { didSet { setNeedsLayout() } }
|
||||
|
||||
/// The offset (in points) of the surface shadow.
|
||||
public var shadowOffset: CGSize = CGSize(width: 0.0, height: 1.0) { didSet { setNeedsLayout() } }
|
||||
@objc dynamic public var shadowOffset: CGSize = CGSize(width: 0.0, height: 1.0) { didSet { setNeedsLayout() } }
|
||||
|
||||
/// The opacity of the surface shadow.
|
||||
public var shadowOpacity: Float = 0.2 { didSet { setNeedsLayout() } }
|
||||
@objc dynamic public var shadowOpacity: Float = 0.2 { didSet { setNeedsLayout() } }
|
||||
|
||||
/// The blur radius (in points) used to render the surface shadow.
|
||||
public var shadowRadius: CGFloat = 3 { didSet { setNeedsLayout() } }
|
||||
@objc dynamic public var shadowRadius: CGFloat = 3 { didSet { setNeedsLayout() } }
|
||||
|
||||
/// The width of the surface border.
|
||||
public var borderColor: UIColor? { didSet { setNeedsLayout() } }
|
||||
@objc dynamic public var borderColor: UIColor? { didSet { setNeedsLayout() } }
|
||||
|
||||
/// The color of the surface border.
|
||||
public var borderWidth: CGFloat = 0.0 { didSet { setNeedsLayout() } }
|
||||
@objc dynamic public var borderWidth: CGFloat = 0.0 { didSet { setNeedsLayout() } }
|
||||
|
||||
/// Offset of the container view from the top
|
||||
public var containerTopInset: CGFloat = 0.0 { didSet {
|
||||
@objc dynamic public var containerTopInset: CGFloat = 0.0 { didSet {
|
||||
setNeedsUpdateConstraints()
|
||||
} }
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ import UIKit
|
||||
|
||||
public class GrabberHandleView: UIView {
|
||||
|
||||
public var barColor = UIColor(displayP3Red: 0.76, green: 0.77, blue: 0.76, alpha: 1.0) { didSet { backgroundColor = barColor } }
|
||||
@objc dynamic public var barColor = UIColor(displayP3Red: 0.76, green: 0.77, blue: 0.76, alpha: 1.0) {
|
||||
didSet { backgroundColor = barColor }
|
||||
}
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
|
||||
Reference in New Issue
Block a user