我正在iPad上的popover中使用UIImagePickerController与前置摄像头拍照.我将allowsEditing设置为YES,并在拍摄照片后获得内置的"移动和缩放"视图中的精彩内容.尽管图像被裁剪为320x320平方(http://dl.dropbox.com/u/2246698/moveAndScale.png),但此视图中的裁剪矩形在屏幕上测量为320x267 .如果我按原样接受图像而不调整大小或移动它,顶部有一个约25像素高的黑条,好像裁剪矩形在图像上的位置太高(http://dl.dropbox.com/u/ 2246698/cropped.png).实际上,如果我从媒体信息字典中获取该裁剪矩形(通过UIImagePickerControllerCropRect),则表明裁剪矩形的y原点为-39.这似乎打破了默认情况下图像将被错误地裁剪,通常当它看起来被打破时,因为我做错了.有没有人见过这个或知道一些对我的庄稼有益的旋风?
非常感谢.
问候!我正在尝试在CALayer中绘制一系列圆圈,这些圆圈位于可缩放的UISCrollView中.这是放大捏的图层.如果我使用CAShapeLayer绘制圆圈,那么它们可以精美地缩放:
CAShapeLayer plotLayer = [CAShapeLayer layer];
plotLayer.bounds = self.bounds;
plotLayer.anchorPoint = CGPointZero;
plotLayer.position = CGPointZero;
CGMutablePathRef path = CGPathCreateMutable();
for (id one in many) {
CGRect ellipseRect = [one circleRect];
CGPathAddEllipseInRect(path, NULL, ellipseRect);
}
plotLayer.path = path
CFRelease(path);
[self.layer addSublayer:plotLayer];
[plotLayer setNeedsDisplay];
Run Code Online (Sandbox Code Playgroud)
然而,当我尝试在我的drawLayer:inContext:方法中使用香草核心图形绘制它们时,圆圈变得非常锯齿(彻头彻尾的专利!)没有任何数量的antialias jiggery-pokery似乎有帮助:
-(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context
{
CGContextSetAllowsAntialiasing(context, true);
CGContextSetShouldAntialias(context, true);
CGContextClip(context);
for (id one in many) {
CGRect ellipseRect = [one circleRect];
CGContextStrokeEllipseInRect(context, ellipseRect);
}
}
Run Code Online (Sandbox Code Playgroud)
我想弄清楚CAShapeLayer正在做些什么来获得如此好的抗锯齿效果(除了我自己的启发)我可以充分利用我的绘图中的核心图形,而不仅仅是我可以用CAShapeLayer获得的笔触/填充.我只是在某个地方错过了一个变换?
非常感谢!