简体   繁体   中英

Shrink a view based on tapping outside, without using gesture recogniser

I have three containers in my landing screen one below the other. The bottommost Container has a behaviour to increase its height based on Tap inside its bounds.

Now, once I tap anywhere on the screen - including the bounds of the said container as well as the other two containers, I want to shrink the container back to the original height.

I am currently doing this by adding a bunch of tap gesture recognisers on the other three containers and checking a boolean value (isShrunk) to do the shrinking. However these gesture recognisers seem unnecessary as all I want to do is on the next touch after the view is increased in height I want to shrink the view.

我可能不太了解您的需求,但是简化它的一种方法是重构代码:一个带有您的轻击手势识别器的父视图类,以及将三个容器作为父子类,即您将手势管理集中在一个地方。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM