UIImageView
에 동그라미를 그려야합니다. 나는 그것을 시도했으나 효과가 없었다. 객관적인 - C에 레이어를 추가하지 않고 UIImageView에서 원을 그리는 방법?
이
내가 무엇을 달성하고자하는의 이미지 예입니다 :원은 사용자가 UIImageView
에 탭 위치에 그려되어야하고, 나는 어떤 sublayer
를 추가하지 않고 그것을 할 싶어.
어떻게해야합니까? 지금까지 인터넷에서이 코드를 사용했지만 작동하지 않았습니다.
- (UIImage *)imageByDrawingCircleOnImage:(UIImage *)image
pointX:(float) x
PointY:(float) y
{
// begin a graphics context of sufficient size
UIGraphicsBeginImageContext(image.size);
// draw original image into the context
[image drawAtPoint:CGPointZero];
// get the context for CoreGraphics
CGContextRef ctx = UIGraphicsGetCurrentContext();
// set stroking color and draw circle
[[UIColor redColor] setStroke];
// make circle rect 5 px from border
CGRect circleRect = CGRectMake(0, 0,
image.size.width,
image.size.height);
circleRect = CGRectInset(circleRect, x, y);
// draw circle
CGContextStrokeEllipseInRect(ctx, circleRect);
// make image out of bitmap context
UIImage *retImage = UIGraphicsGetImageFromCurrentImageContext();
// free the context
UIGraphicsEndImageContext();
return retImage;
}
은 당신이 무엇을 시도했다 공유 할 수 없습니다 도움이 될 것입니다
희망이 코드를 추가, 예를 들어 둥근
imageView
의 모양에 따라 이미지를 설정 지금까지? – lsouza
어쨌든 iOS 4를 사용하고 있다고 생각하지 않습니다. 올바르게 태그를 지정하십시오. – rmaddy
너비의 반쪽에 모서리 반경을 준다 –