gpt4 book ai didi

cocoa - NSView - 在什么条件下边界和框架*大小*可能不相等?

转载 作者:行者123 更新时间:2023-12-03 17:13:32 24 4
gpt4 key购买 nike

我知道frame是 View 相对于其父 View 的框架,bounds是 View 的内部边界(除了 ScrollView 之外,原点总是[0, 0]?)。

但是,我不清楚在什么条件下框架和边界大小可能会有所不同(如果有的话)。 Apple 官方文档是否说明是 frame.size =bounds.size 还是 frame.size ?=bounds.size

最佳答案

你可以在界限内做任何你想做的事。想象一下你的视野是一幅画,你只能通过相机来观看。移动原点将改变您当前通过移动相机可以看到的绘画部分。缩小尺寸会放大,因此可见的绘画部分会减少,但看起来会更大。扩大尺寸会缩小,这样可以看到更多的画作,但它看起来更小。

来自documentation for bounds :

By default, the origin of the returned rectangle is (0, 0) and its size matches the size of the receiver’s frame rectangle (measured in points)....

If you explicitly change the origin or size of the bounds rectangle, this method does not return the default rectangle and instead returns the rectangle you set. If you add a rotation factor to the view, however, that factor is also reflected in the returned bounds rectangle.

来自documentation for setBounds: :

The bounds rectangle determines the origin and scale of the receiver’s coordinate system within its frame rectangle....

After calling this method, NSView creates an internal transform (or appends these changes to an existing internal transform) to convert from frame coordinates to bounds coordinates in your view. As long as the width-to-height ratio of the two coordinate systems remains the same, your content appears normal. If the ratios differ, your content may appear skewed.

关于cocoa - NSView - 在什么条件下边界和框架*大小*可能不相等?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13773050/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com