我的 iOS 视图偏离了半个像素?

发布于 2024-10-24 02:05:57 字数 159 浏览 11 评论 0原文

除非我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冬天旳寂寞 2024-10-31 02:05:57

查看是否在某处使用视图的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文