Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Chirone

macrumors 6502
Original poster
Mar 2, 2009
279
0
NZ
i'm trying to get a text layer and just a normal CA layer (so i can use core graphics on it) to start in a particular position

right now the textlayer does not show up unless it has a constraint applied to it

which is pointless since constraining the width doesn't scale the layer (just the box), which is what i need...
the whole
Code:
[wordOne setValue: [NSNumber numberWithFloat: 200] forKeyPath: @"transform.translation.x"];
line doesn't have any effect, and calling setNeedsDisplay doesn't do anything either :confused: (regardless of whether or not the layer is constrained)

if that's not the correct way to change the position of something then i'm totally lost... i suppose i could use the constraint's offset for translation, but that doesn't help for trying to rotate and scale the layers...
 
The frame (position and bounds) must be set inorder for a layer to be visible. A textLayer uses bounds for wrapping, if you want to "scale" the layer you'll have to change the font size.
 
so unless the frame and bounds are constrained the layer has 0 frame and bounds?
that just sounds silly :rolleyes:
oh well... i guess it's all guess and check for deciding the tightest frame and bounds... seems pretty silly to me. knowing the width of a word seems to be the most useful thing for my app but it's just not something that can be obtained easily

look's like i will have to use a normal CALayer with core graphics on it to get proper scaling of text too... seeing as how scaling a text layer doesn't actually scale the contents :(

thanks for the clarification whiterabbit :)
 
If you set the layer frame via setFrame or setBounds and setPosition you shouldn't need to use a constraint.

If you center the text virtically and horizontally in the layer (and the layer is bigger than the text) you could use the fontSize property in an animation or whatever to scale the text.
 
If you set the layer frame via setFrame or setBounds and setPosition you shouldn't need to use a constraint.
i know that, i'm just saying it's silly that you have to manually set it yourself for a CATextLayer, it should automatically resize as the text changes
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.