如何制作不规则形状uiview并将uiimageview放入那些形状如instacollage iphone app

Him*_*dav 6 iphone shape frames uiview

我正在制作照片拼贴iphone应用程序,我必须在每个形状内部制作不规则形状相框,将有一个带手势的uiimageview,在点击形状我需要为该形状选择一张照片,这些框架非常类似于框架instacollage iPhone应用程序.链接:https://itunes.apple.com/in/app/instacollage-pro-pic-frame/id530957474?mt = 8

为我提供了一些如何完成这项任务的方向.

谢谢

小智 2

您可以使用图层的 Mask 属性来实现此目的。

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;
Run Code Online (Sandbox Code Playgroud)