I have a problem to create image of irregular shape. This is example of my frame.
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.
I have a problem to create image of irregular shape. This is example of my frame.
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.
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...
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];
}
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;