1

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!

Alex Cio
  • 6,014
  • 5
  • 44
  • 74
heming
  • 93
  • 10
  • You could probably google out existing components for this, like https://www.cocoacontrols.com/controls/wcbeforeafter , inspire yourself from their source code or do come back with more detailed and specific-issue question. – PetrV Nov 02 '15 at 15:56

1 Answers1

1

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;
}];
Alex Cio
  • 6,014
  • 5
  • 44
  • 74
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143