2012-11-01 13 views
6

Sto lavorando ad un'app per iPhone con collage di foto e devo creare cornici di forma irregolare all'interno di ogni forma ci sarà una visuale con i gesti, toccando la forma che ho bisogno di scegliere una foto per quella forma, questi fotogrammi sono molto simili ai fotogrammi di iPhone app instacollage. link: https://itunes.apple.com/in/app/instacollage-pro-pic-frame/id530957474?mt=8come rendere uiview forma irregolare e mettere l'immagine uiimageview in quelle forme come l'app iphone instacollage

fornire un tipo di direzione come eseguire questa operazione.

Grazie

+0

si potrebbe essere alla ricerca di UICollectionView http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12 – iosMentalist

risposta

2

È possibile utilizzare la proprietà Maschera dello strato per raggiungere questo obiettivo.

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; 
0

Grazie Sahana. Il codice equivalente a Swift è:

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 
Problemi correlati