6

I am working on a photo collage iphone app and i have to make irregular shape photo frames inside each shape there will be a uiimageview with gestures, on tapping the shape i need to pick a photo for that shape, these frames are very similar to frames of instacollage iphone app. link : https://itunes.apple.com/in/app/instacollage-pro-pic-frame/id530957474?mt=8

provide me some kind of direction how to do this task.

Thanks

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
  • you might be looking for UICollectionView http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12 – iosMentalist Mar 11 '14 at 21:00

2 Answers2

2

You can use Mask property of the layer to achieve this.

CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = self.imageView.bounds ;
UIBezierPath *roundedPath = [UIBezierPath bezierPathWithOvalInRect:maskLayer.frame];
maskLayer.fillColor = [[UIColor whiteColor] CGColor];
maskLayer.backgroundColor = [[UIColor clearColor] CGColor];
maskLayer.path = [roundedPath CGPath];

// Add mask
self.imageView.layer.mask = maskLayer;
Sahana Kini
  • 562
  • 2
  • 8
0

Thanks Sahana. The equivalent code in Swift is:

let maskLayer = CAShapeLayer()
maskLayer.frame = self.imageView.bounds
let roundedPath = UIBezierPath(ovalInRect: maskLayer.frame)
maskLayer.fillColor = UIColor.whiteColor().CGColor
maskLayer.backgroundColor = UIColor.clearColor().CGColor
maskLayer.path = roundedPath.CGPath
self.imageView.layer.mask = maskLayer
Michiel Overtoom
  • 1,609
  • 13
  • 14