简体   繁体   中英

Drag And Swap Two UIScrollViews (Hover & Swap Effect)

I am creating a photo editor in my app and working on a multiple picture layout option.

Currently when the user takes a picture, I display their image in UIImageView nested in a UIScrollView. The reason I nest it in a UIScrollView is so I can pan and zoom.

In the situation where the user selects duo layout mode, the app puts 2 images side by side (so 2 UIScrollViews).

If they hold a finger on one UIScrollView I want to raise the UIScrollView up a tad and give it a drop shadow.

I have a long way of doing this, but I was curious if there was anything in the native libraries that will let me automatically create this hover effect for dragging a view class.

Thanks

在此处输入图片说明

No, there isn't any preexisting functionality for this. You can add shadow and animate a "lift" motion yourself with something like this:

// define dragged somewhere as the UIView subclass of your choosing
dragged.layer.shadowColor = [UIColor blackColor].CGColor;
dragged.layer.shadowOffset = CGSizeMake(-2, 2);
dragged.layer.masksToBounds = NO;
dragged.layer.shadowRadius = 4;
dragged.layer.shadowOpacity = .7;
[UIView animateWithDuration:.2 delay:0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{self.draggedPhoto.transform = CGAffineTransformMakeScale(1.2, 1.2);}
                 completion:nil];

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