简体   繁体   中英

Animating Subview's Frame In A UIScrollView

I have a subview inside a horizontal UIScrollView .

The subview's frame changes when a vertical UISwipeGestureRecognizer is triggered.

However, if the user swipes diagonally by mistake, the subview's frame does not really change.

Well, technically it does, but you see a very quick flash - where you see it change but then immediately go back to its original frame .

The scrollview has paging enabled - so maybe it goes back to the current page's location?

How do I get the subview's frame to change (without reverting back)?

I have tried using various options like UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionLayoutSubviews. Currently I am calling animateWithDuration:delay:options:animation:completion when a vertical swipe is registered

您应该在方法结尾尝试使用CGRectMake。

subview.frame = CGRectMake(x, y, width, height);

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