【问题标题】:CGAffineTransformMakeRotation UIImageViewCGAffineTransformMakeRotation UIImageView
【发布时间】:2012-09-03 12:37:46
【问题描述】:

我有一个 UIImageView,我想在逆时钟方向稍微旋转它。但是当我这样做时,旋转就起作用了。但是边缘不共享。具有像素化边缘。我该如何解决这个问题。请帮忙。

UIImageView *popupTop = [[UIImageView alloc] initWithFrame:CGRectMake(10, 54, 300, 15)];
popupTop.image = [UIImage imageNamed:@"pover_note.png"];
[self.view addSubview:popupTop];

popupTop.transform = CGAffineTransformMakeRotation(-0.04);

【问题讨论】:

  • 能否请您显示原始图像以及前卫的结果?

标签: objective-c uiimageview cgaffinetransform image-rotation


【解决方案1】:

在 info.plist 中添加一个键 使用边缘抗锯齿渲染并将其值设置为 YES

【讨论】:

  • 是的,这可能会导致一些性能问题,但您可以尝试检查性能问题是否明显,如果没有,那么您的问题已经解决
【解决方案2】:

您可以在 Info.plist 中设置一个启用边缘抗锯齿功能的键:UIViewEdgeAntialiasing

【讨论】:

    【解决方案3】:

    如果您不希望UIViewEdgeAntialiasing 对性能造成潜在影响或可能产生其他副作用,那么最简单的方法是在图像周围制作透明像素边框 :)

    【讨论】:

    • 我不想遇到任何性能问题。你能告诉我如何在图像周围添加透明边框吗?我试过这个。但没有运气。
    • codeCGRect imageRrect = CGRectMake(0, 0, popupTop.image.size.width, popupTop.image.size.height); UIGraphicsBeginImageContext(imageRrect.size); [popupTop.image drawInRect:CGRectMake(1,1, popupTop.image.size.width-2, popupTop.image.size.height-2)]; popupTop.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); code
    • 不,我的意思是 在图像中 - 使用 Photoshop :)
    猜你喜欢
    • 2015-02-06
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多