我的 iOS 视图偏离了半个像素?
除非我在 Y 坐标上添加或减去半个像素,否则我的图形看起来很模糊。
我知道这是将坐标设置为子像素值时通常会发生的症状。这让我相信我的某个观点一定是错误的。
但我检查了窗口、视图控制器和子视图,没有看到任何具有子像素值的原点或中心。
我很困惑,有什么想法吗?
My graphics are looking blurry unless I add or subtract a half pixel to the Y coordinate.
I know this is a symptom that usually happens when the coordinates are set to sub-pixel values. Which leads me to believe one of my views must be off or something.
But I inspected the window, view controller and subviews, and I don't see any origins or centers with sub-pixel values.
I am stumped, any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看是否在某处使用视图的 center 属性。如果将其分配给其他子视图,根据它们的大小,它们可能会将自己定位在半像素值中。
另外,如果您使用代码生成 UI,我建议使用 https://github.com/domesticcatsoftware/DCIntrospect< /a>.该工具允许您在模拟器中查看可见小部件的所有几何形状。对于整数坐标,半像素视图以红色与蓝色突出显示。这很有帮助。
See if somewhere you are using the center property of a view. If you assign that to other subviews, depending on their sizes they may position themselves in half pixel values.
Also, if you are using code to generate the UI I would suggest using https://github.com/domesticcatsoftware/DCIntrospect. This tools allows you in the simulator to look at all the geometry of visible widgets. Half pixel views are highlighted in red vs blue for integer coordinates. It helps a lot.