【问题标题】:CALayer border get fuzzy on rotationCALayer 边框在旋转时变得模糊
【发布时间】:2012-04-03 07:14:41
【问题描述】:

我正在使用 UIColor* clear = [UIColor blackColor]; [self.layer setBorderColor:[color CGColor]];

为图像设置边框。它正在添加边框,但是当我尝试将该图像旋转到 45 度、90 度等时,该边框开始变得模糊并且不再固定或笔直。无论我做什么,如何将边框像一条线一样固定..

【问题讨论】:

标签: iphone objective-c ios


【解决方案1】:
UIColor* clear = [UIColor blackColor]; [self.layer setBorderColor:[color CGColor]];

看起来很奇怪;\ 这里的 self 是什么? 尝试

UIImageView *imgView = [[UIImageView alloc] setImage:[UIImage imageNamed:@"pic.png"]];
[self.view addSubview:imgView];
imgView.layer.borderWidth = 2.0f;
imgView.layer.borderColor = [[UIColor blackColor] CGColor];

别忘了包含 QuartzCore 框架和#import <QuartzCore/QuartzCore.h>

【讨论】:

  • 我正在为 UIImageView 创建自定义类,这就是 self.
  • 我认为您应该尝试设置边框属性超出自我,在 superview 中的某个位置,您将图像添加为子视图,就像我写的那样,只是为了实验
  • 但是如果你关于像素化 - 查看@George 的链接
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-08
  • 1970-01-01
  • 2015-06-15
  • 1970-01-01
  • 2012-01-05
  • 2017-04-19
相关资源
最近更新 更多