Con il codice seguente, sto mascherando con successo parte del mio disegno, ma è l'inverso di ciò che voglio mascherato. Questo maschera la parte interna del disegno, dove vorrei mascherare la parte esterna. C'è un modo semplice per invertire questa maschera?Maschera invertita iOS in drawRect
myPath
di seguito è un UIBezierPath
.
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
CGMutablePathRef maskPath = CGPathCreateMutable();
CGPathAddPath(maskPath, nil, myPath.CGPath);
[maskLayer setPath:maskPath];
CGPathRelease(maskPath);
self.layer.mask = maskLayer;
Può essere che si può rispondere a questa domanda anche: http://stackoverflow.com/questions/30360389/ use-layer-mask-to-make-parts-of-the-uiview-transparent – confile
Questa risposta è ottima e funziona in modo impeccabile. –
è stato rimosso CGPathRelease (maskPath)? funziona, ma posso ottenere una perdita di memoria? (Swift 2.2, iOS 9.0) Impossibile trovare alcun riferimento ad esso. – Maik639