Before/after iOS tool

91 Views Asked by At

I want to make something like this:

enter image description here Reference of image.

What I do: two UIImagesView, one with UIViewContentModeLeft and another with UIViewContentModeRight. I have a slider where I can change image frames. The solution seems to be ok, but I am not sure if this is the "right" one. Other suggestions are welcome.

Thanks!

1

There are 1 best solutions below

0
On

use single Imageview for your concept it is my suggestion If you feel free use this else use your concept else go some thirdparty, where you need for modify the transparent, add the one Transparent UIView above the ImageView . set the frame as of Transparent UIView for Show as (0, 0, ImageView.frame.size.width/2,ImageView.frame.size.height) , for Hide (ImageView.frame.origin.X - 40, 0, ImageView.frame.size.width/2,ImageView.frame.size.height)

for example

To Show

TransparentView.hidden = NO;
TransparentView.alpha = 0.1;
[UIView animateWithDuration:0.25 animations:^{
     TransparentView.frame =   CGRectMake(0, 
                                          0, 
                                          ImageView.frame.size.width/2,
                                          ImageView.frame.size.height);
    TransparentView.alpha = 1.0f;
} completion:^(BOOL finished) {
    // do some
}];

To hide

[UIView animateWithDuration:0.25 animations:^{
    TransparentView.frame = CGRectMake(0 - self.view.frame.size.width, 
                                       0, 
                                       ImageView.frame.size.width/2,
                                       ImageView.frame.size.height);
    [TransparentView setAlpha:0.1f];
} completion:^(BOOL finished) {
    TransparentView.hidden = YES;
}];