圖片擦除
// 獲取當(dāng)前點(diǎn)
CGPoint curP = [pan locationInView:self.view];
// 獲取擦除的矩形范圍
CGFloat wh = 100;
CGFloat x = curP.x - wh * 0.5;
CGFloat y = curP.y - wh * 0.5;
CGRect rect = CGRectMake(x, y, wh, wh);
// 開啟上下文
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0);
CGContextRef ctx = UIGraphicsGetCurrentContext();
// 控件的layer渲染上去
[_imageView.layer renderInContext:ctx];
// 擦除圖片
CGContextClearRect(ctx, rect);
// 生成一張圖片
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
_imageView.image = image;
// 關(guān)閉上下文
UIGraphicsEndImageContext();
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者