UIImageView的initWithImage变形
我正在使用类似于以下的代码从 PNG 图像创建一个计数器:
counterImage = [UIImage imageNamed:@"counter-1-2-inactive.png"];
UIImageView *counterImageView = [[[UIImageView alloc] initWithImage:counterImage] autorelease];
UILabel *countLabel = [[[UILabel alloc] initWithFrame:counterImageView.frame] autorelease];
[cell addSubview:counterImageView];
[counterImageView addSubview:countLabel];
您可以在下面看到结果,在左侧有一个来自 iOS 模拟器的计数器,在右侧有一个原始的 PNG。
为什么生成的 UIImageView 的质量略有下降?我该如何改进它?这可能只是 1 像素高度的线,但在 1:1 比例下,似乎计数器比上面的缩短了。
生成的 counterImageView 的大小与原始 PNG 相同:40x24。
I'm creating a counter from PNG image using code similar to:
counterImage = [UIImage imageNamed:@"counter-1-2-inactive.png"];
UIImageView *counterImageView = [[[UIImageView alloc] initWithImage:counterImage] autorelease];
UILabel *countLabel = [[[UILabel alloc] initWithFrame:counterImageView.frame] autorelease];
[cell addSubview:counterImageView];
[counterImageView addSubview:countLabel];
You can see a result below, on the LHS there is a counter from iOS Simulator and on the RHS there is a original PNG.
Why the quality decreased slightly in the resulting UIImageView? How can I improve it? This is maybe only 1-pixel-height line, but in 1:1 scale is seems like a counter is shortened from the above.
Size of a resulting counterImageView is the same as original PNG: 40x24.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有时,人们只需要提出一个问题即可在“相关”部分中找到解决方案...;-)
我根据对此问题的评论应用了 1px 透明边框:旋转 UIImageView 是否有快速而肮脏的抗锯齿技术?
Sometimes one just needs to ask a question to find a solution in a "Related" section... ;-)
I applied a 1px transparent border based on comments on this question: Any quick and dirty anti-aliasing techniques for a rotated UIImageView?