A prima vista la mia domanda sembra davvero semplice, ma sembra che non riesca davvero a trovare una soluzione. Ecco cos'è: Voglio calcolare il riquadro di delimitazione della stringa di un CATextLayer. Ecco quello che faccio:Come calcolare il riquadro di delimitazione della stringa di un CATextLayer?
CATextLayer *textLayer = [CATextLayer layer];
textLayer.frame = CGRectMake(80, 0.0f, 36.0f, 18.0f);
textLayer.string = @"12";
textLayer.fontSize = [UIFont systemFontSize];
textLayer.foregroundColor = [UIColor whiteColor].CGColor;
NSLog(@"(width,height)=(%f,%f)",
[textLayer.string sizeWithFont:textLayer.font].width,
[textLayer.string sizeWithFont:textLayer.font].height);
Il problema è che l'uscita è sempre: (larghezza, altezza) = (8.000000,0.000000)