1

I have a problem to create image of irregular shape. This is example of my frame.

Frame containing two parts of odd shape

Please give any idea for creating image like this. It is containing two image in two different frame. But both images hides some part of it after fitting in frame.

aks.knit1108
  • 1,305
  • 9
  • 20
  • the solution would be u have to have the image frame as image with the center being transparent and put the actual image behind – Mudit Bajpai Jul 07 '12 at 18:09

3 Answers3

0

You have to create mask image that will mask out part off original image.. try looking at How to Mask an UIImageView it might be helpful...

Community
  • 1
  • 1
kviksilver
  • 3,824
  • 1
  • 26
  • 27
  • No you are not getting my question. Both images are of actual size when i am touching or zooming the image, means of rectangular shape. Only view of image is like that something is hiding a part of image. – aks.knit1108 Jul 05 '12 at 11:27
0

You can use a mask:

- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage
{
    CGImageRef maskRef = maskImage.CGImage; 

    CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
                                    CGImageGetHeight(maskRef),
                                    CGImageGetBitsPerComponent(maskRef),
                                    CGImageGetBitsPerPixel(maskRef),
                                    CGImageGetBytesPerRow(maskRef),
                                    CGImageGetDataProvider(maskRef), NULL, false);

    CGImageRef masked = CGImageCreateWithMask([image CGImage], mask);

    return [UIImage imageWithCGImage:masked];
}
  • image is your original image .
  • maskImage is an b/w image. Where the maskImage is black your original image will be showed.
Atulkumar V. Jain
  • 5,102
  • 9
  • 44
  • 61
cark
  • 254
  • 2
  • 9
  • No you are not getting my question. Both images are of actual size when i am touching or zooming the image, means of rectangular shape. Only view of image is like that something is hiding a part of image – aks.knit1108 Jul 05 '12 at 11:29
0

U will need bordered image to mask your imagview's image. Now do this:

 #import <QuartzCore/QuartzCore.h>
 // remember to include Framework as well

CALayer *mask = [CALayer layer];
mask.contents = (id)[[UIImage imageNamed:@"bordered_image_mask.png"] CGImage]; // here bordered image
mask.frame = CGRectMake(5, 5, <img_width>, <img_height>); // here x and y is 5 to show white boder around like in image
yourImageView.layer.mask = mask;
yourImageView.layer.masksToBounds = YES;
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
  • Image is added on scrollview, so first time it is showing like this. But actually when i touch or slide then this is of rectangular shape !! – aks.knit1108 Jul 05 '12 at 11:50