CTFrame and drawing text + layers.

  • Hi

    I want to stop the CATextLayer from adjusting the boundaries of my
    text when I've got text wrapping turned on and the parent layer has a
    layout manager attached to it.  I'd like the CATextLayer simply to use
    the boundaries that I provide it.

    The docs state:
    Note: When a CATextLayer instance is positioned using the
    CAConstraintLayoutManager Class Reference the bounds of the object is
    resized to fit the text content.

    Is there a way of forcing it NOT to do this somehow?  Something I can
    override perhaps?

    --
    John Clayton
    http://www.coderage-software.com/
  • You could try overriding the -preferredFrameSize method to something
    like this:

    - (CGSize)preferredFrameSize
    {
      CGSize sz = CGSizeApplyAffineTransform ([self bounds].size, [self
    affineTransform]);
      sz.width = ceil (sz.width); sz.height = ceil (sz.height);
      return sz;
    }

    this will tell the layout manager that the text layer's ideal size is
    its current size. It may still get resized depending on how the
    parent's layout manager has been configured,

    John

    On Nov 19, 2007, at 9:39 AM, John Clayton wrote:

    > Hi
    >
    > I want to stop the CATextLayer from adjusting the boundaries of my
    > text when I've got text wrapping turned on and the parent layer has
    > a layout manager attached to it.  I'd like the CATextLayer simply to
    > use the boundaries that I provide it.
    >
    > The docs state:
    > Note: When a CATextLayer instance is positioned using the
    > CAConstraintLayoutManager Class Reference the bounds of the object
    > is resized to fit the text content.
    >
    > Is there a way of forcing it NOT to do this somehow?  Something I
    > can override perhaps?
    >
    > --
    > John Clayton
    > http://www.coderage-software.com/
  • that was *exactly* what I needed by the way - THANK YOU.

    On 19/11/2007, at 7:49 PM, John Harper wrote:

    > You could try overriding the -preferredFrameSize method to something
    > like this:
    >
    > - (CGSize)preferredFrameSize
    > {
    > CGSize sz = CGSizeApplyAffineTransform ([self bounds].size, [self
    > affineTransform]);
    > sz.width = ceil (sz.width); sz.height = ceil (sz.height);
    > return sz;
    > }
    >
    > this will tell the layout manager that the text layer's ideal size
    > is its current size. It may still get resized depending on how the
    > parent's layout manager has been configured,
    >
    > John
    >
    >
    > On Nov 19, 2007, at 9:39 AM, John Clayton wrote:
    >
    >> Hi
    >>
    >> I want to stop the CATextLayer from adjusting the boundaries of my
    >> text when I've got text wrapping turned on and the parent layer has
    >> a layout manager attached to it.  I'd like the CATextLayer simply
    >> to use the boundaries that I provide it.
    >>
    >> The docs state:
    >> Note: When a CATextLayer instance is positioned using the
    >> CAConstraintLayoutManager Class Reference the bounds of the object
    >> is resized to fit the text content.
    >>
    >> Is there a way of forcing it NOT to do this somehow?  Something I
    >> can override perhaps?
    >>
    >> --
    >> John Clayton
    >> http://www.coderage-software.com/
    >
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today