2011-03-16 6 views
0

이것은 내 코드입니다. 이 코드를 사용하여 imageView.image 만 지우고 있지만 이미지 뷰 하위 뷰도 지우고 싶습니다. imageView에서 하위 뷰를 지우려면 어떻게해야합니까?보기에서 하위보기를 지우는 방법은 무엇입니까?

UIGraphicsBeginImageContext(imageView.frame.size); 
[imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)]; 
CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone); //kCGImageAlphaPremultipliedLast); 
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10); 
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10); 
CGContextBeginPath(UIGraphicsGetCurrentContext()); 
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), point.x, point.y); 
//this line code for erasing select the part of the image 
CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(point.x, point.y, 30, 30)); 
//End the code 
CGContextStrokePath(UIGraphicsGetCurrentContext()); 
imageView.image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

답변

1

[imageView removeFromSuperview]을 사용해 보셨습니까? 당신이 어떤 이유로 모든 하위 뷰를 제거하려는 경우

0

, 당신은 시도 할 수 있습니다 :

for (UIView *view in imageView.subviews) { 
    [view removeFromSuperview]; 
} 
관련 문제