Esto es bastante el iPhone quandry. Estoy trabajando en una biblioteca, pero he reducido mi problema a un código muy simple. Lo que hace este código es crear una vista de 50x50, aplica una transformación de rotación de algunos grados y luego baja el marco varias veces. El resultado es que la vista 50x50 ahora es mucho más grande.¿Girar usando una transformación, luego cambiar el origen del marco y ver expandir?
Aquí está el código:
// a simple 50x50 view
UIView *redThing = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];
redThing.backgroundColor = [UIColor redColor];
[self.view addSubview:redThing];
// rotate a small amount (as long as it's not 90 or 180, etc.)
redThing.transform = CGAffineTransformRotate(redThing.transform, 0.1234);
// move the view down 2 pixels
CGRect newFrame = CGRectMake(redThing.frame.origin.x, redThing.frame.origin.y + 2, redThing.frame.size.width, redThing.frame.size.height);
redThing.frame = newFrame;
// move the view down another 2 pixels
newFrame = CGRectMake(redThing.frame.origin.x, redThing.frame.origin.y + 2, redThing.frame.size.width, redThing.frame.size.height);
redThing.frame = newFrame;
// move the view down another 2 pixels
newFrame = CGRectMake(redThing.frame.origin.x, redThing.frame.origin.y + 2, redThing.frame.size.width, redThing.frame.size.height);
redThing.frame = newFrame;
// move the view down another 2 pixels
newFrame = CGRectMake(redThing.frame.origin.x, redThing.frame.origin.y + 2, redThing.frame.size.width, redThing.frame.size.height);
redThing.frame = newFrame;
Entonces, ¿qué diablos está pasando? Ahora, si muevo la vista aplicando una transformación de traducción, funciona bien. Pero eso no es lo que quiero hacer y este debería funcionar de todos modos.
¿Alguna idea?
¿Quizás la transformación se está aplicando después de los turnos? – Artelius