Note that there are some explanatory texts on larger screens.

plurals
  1. POCore animation geometry for layer-backed view
    primarykey
    data
    text
    <p>I have a layer-backed view, and want to understand how anchor point works for it and is it allowed at all to work with CALayer geometry properties (instead of using frame property of NSView)</p> <p>First, quote from documentation:</p> <blockquote> <p>The default value for anchorPoint is (0.5,0.5) which corresponds to the center of the layer's bounds</p> </blockquote> <p>But when I try to change value of anchor point to (0.5,0.5) directly, I got offset. Here is example, red area is the original position (when nothing applied to the anchor point), the button was moved to the bottom-left corner:</p> <p><img src="https://i.stack.imgur.com/LhcAb.png" alt="enter image description here"></p> <p>When I set anchor point to (0,0) button placed where it should be:</p> <p><img src="https://i.stack.imgur.com/TiKhb.png" alt="enter image description here"></p> <p><strong>Update</strong>:</p> <p>Here is the code I use to instantiate Button:</p> <pre><code>self.button = [[NSButton alloc] initWithFrame:NSMakeRect(130, 130, 100, 40)]; self.button.title = @"My Title"; self.button.wantsLayer = YES; NSLog(@"Button anchor Point is : (%f;%f)", self.button.layer.anchorPoint.x, self.button.layer.anchorPoint.y); [panelView addSubview:self.button]; </code></pre> <p>What interesting, seems that for layer-backed view's the default anchor point is 0,0:</p> <pre><code>NSLog(@"Button anchor Point is : (%f;%f)", self.button.layer.anchorPoint.x, self.button.layer.anchorPoint.y); </code></pre> <p>produces (0.000000;0.000000)</p> <p>After all, OS X Deployment target is 10.8</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload