Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ihormalovanyi committed Jan 18, 2020
2 parents 74cd2e2 + 8006dcf commit ea73489
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions SweetCurtain/Controllers/CurtainController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ open class CurtainController: UIViewController {
internal var curtainHeightProvider = CurtainHeightProvider()
internal var curtainHandleIndicatorColor: UIColor = UIColor.lightGray.withAlphaComponent(0.8) {
didSet {
curtainHandleView?.backgroundColor = curtainHandleIndicatorColor
curtainHandleView.backgroundColor = curtainHandleIndicatorColor
}
}
internal var curtainActualHeight: CGFloat {
Expand Down Expand Up @@ -88,7 +88,7 @@ open class CurtainController: UIViewController {
private var scrollStartLocation: CGPoint = .zero
private var scrollFreezeContentOffset = false

private var curtainHandleView: UIView!
private lazy var curtainHandleView: UIView = .init()
private var curtainActualHeightState: CurtainHeightState = .hide {
didSet {
guard curtainActualHeightState != oldValue else { return }
Expand Down Expand Up @@ -145,6 +145,10 @@ open class CurtainController: UIViewController {
firstLayout = false
}

open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
curtainHandleView.center = .init(x: size.width / 2, y: Constants.curtainHandleYCenter)
}

///Changes a curtain position you want.
///- Parameter position: The position of the curtain to be applied.
///- Parameter animated: Pass true to animate the position change.
Expand All @@ -153,7 +157,7 @@ open class CurtainController: UIViewController {
}

private func addCurtainHandleView() {
curtainHandleView = .init(frame: .init(origin: .zero, size: Constants.curtainHandleViewSize))
curtainHandleView.frame = .init(origin: .zero, size: Constants.curtainHandleViewSize)
curtainHandleView.backgroundColor = curtainHandleIndicatorColor
curtainHandleView.layer.cornerRadius = curtainHandleView.frame.height / 2
curtainHandleView.alpha = 0
Expand Down

0 comments on commit ea73489

Please sign in to comment.