applidium / OverlayContainer

Non-intrusive iOS UI library to implement overlay based interfaces
https://gaetanzanella.github.io/2018-12-17/replicating-apple-maps-overlay
Other
1.15k stars 94 forks source link

How to get the current container notch #63

Closed zhoujun706 closed 4 years ago

zhoujun706 commented 4 years ago

as title

zhoujun706 commented 4 years ago

or notch index

zhoujun706 commented 4 years ago

the delegate function just can get after notch index, i want to get the index before change

gaetanzanella commented 4 years ago

Please read the README https://github.com/applidium/OverlayContainer#tracking-the-overlay

func overlayContainerViewController(_ containerViewController: OverlayContainerViewController,
                                    willMoveOverlay overlayViewController: UIViewController,
                                    toNotchAt index: Int)
zhoujun706 commented 4 years ago

this function index is toNotch , i want current notch, how can i get this like containerControlloer.currentNotchIndex

zhoujun706 commented 4 years ago

I just use moveOverlay() function, but i want recorde the notchindex before move

zhoujun706 commented 4 years ago

thankyou

gaetanzanella commented 4 years ago

You have to track the current index yourself:


var lastNotchReached = 0

func overlayContainerViewController(_ containerViewController: OverlayContainerViewController,
                                    didMoveOverlay overlayViewController: UIViewController,
                                    toNotchAt index: Int) {
    self.lastNotchReached = index
}
``
zhoujun706 commented 4 years ago

thanks for your reply.

I will draw a picture for you tomorrow, then you will understand . Today is too late thanks again

zhoujun706 commented 4 years ago

Hello , please see this: 截屏2020-04-29 10 27 25 thank you

gaetanzanella commented 4 years ago

I don't understand… since your overlay moved to the top, you should have a callback. I don't see it on your image.

zhoujun706 commented 4 years ago

For example, the KVO can get old value and new value. And now the OverlayContainerViewControllerDelegate function just can get the new value(index), I want the old value(index) .

Thank you : )

gaetanzanella commented 4 years ago

If you do https://github.com/applidium/OverlayContainer/issues/63#issuecomment-620578139, lastNotchReached will correspond to the previous notch index

zhoujun706 commented 4 years ago

All right, thank you . I solve the problem as you say, but I define a property to recorde can or not update last index. Thank you