title: Custom progress bar using image
body: <p>I am working on a custom progress bar that will display a part of an image based on percentage value. My idea was to have two images, original and b&amp;w version. I am displaying the b&amp;w and on top of that I'm cropping, based on percentage, the original image. Is working great but from top to bottom.</p>
  
  <p>I would like to ask, there is any way to make the original image to "grow" from bottom to top? </p>
  
  <p>Below is a sample of my code until now:</p>
  
  <pre><code>    UIImageView *imgDefViewGray = [[UIImageView alloc] initWithFrame:CGRectMake(170, 85, 60, 60)];
      imgDefViewGray.image = [UIImage imageNamed:@"castle-gray.png"];
      [self addSubview:imgDefViewGray];
  
      UIImageView *imgDefView = [[UIImageView alloc] initWithFrame:CGRectMake(170, 85, 60, 60)];
      imgDefView.image = [UIImage imageNamed:@"castle.png"];
  
      CGRect rect = CGRectMake(0, 0 , 60, **50**);
      CGImageRef imageRef = CGImageCreateWithImageInRect([imgDefView.image CGImage], rect);
      UIImage *img = [UIImage imageWithCGImage:imageRef];
  
      imgDefView = [[UIImageView alloc] initWithFrame:CGRectMake(170, 85, 60, **50**)];
      imgDefView.image = img;
      [self addSubview:imgDefView];
  </code></pre>
  
  <p>So, by changing the value on <strong>Bold</strong>(double asterisks), I have achieved to crop the original image as much as I want but with direction top->bottom. I would like it bottom->top.</p>
  
  <p>Thanks in advance</p>