음, 사용자 지정 UIView 하위 클래스를 만들고 drawRect 메서드를 사용하여 부분을 그립니다. 예를 FO :
- (무효)의 drawRect :(
CGRect)rect
{
[super drawRect:rect];
CGContextRef ctx = UIGraphicsGetCurrentContext(); // get drawing context
CGContextSaveGState(ctx); //remember current state
CGContextClipToRect(ctx, CGRectMake(0, 0, 100, 100)); //set clipping
CGContextDrawImage(ctx, CGRectMake(0, 0, img.size.width, img.size.height), img.CGImage);
CGContextRestoreGState(ctx); //restore state, so the previous clipping will be canceled
CGContextSaveGState(ctx);
CGContextClipToRect(ctx, CGRectMake(100, 100, 100, 100));
CGContextDrawImage(ctx, CGRectMake(0, 0, img.size.width, img.size.height), img.CGImage);
CGContextRestoreGState(ctx);
}
이 두 개의 작은의 구형을 그릴 것이 코드 IMG가있는 UIImage이다에서
이
그러나이 할 수있는 가장 쉬운 방법입니다.. CGContextClipToRects와 CGContextClip 함수를 검사하여 더 효율적이고 유연하게 만들 수 있습니다.
오, 많은 감사합니다. 두 개의 작은 rects 거꾸로 나타나는 ...) 어쨌든 아주 좋은 s tart point;) – xabaras78
그리고 CGContextDrawImage를 [img drawAtPoint : CGPointMake (0,0)]로 바꾸어서 해결했습니다. :) – xabaras78