Ho creato due istanze di UILabel
e le ho aggiunte alla vista del mio ViewController
. E poi ho cambiato il anchorPoint
di ciascuno da 0,5 a 1,0 (xey).Perché la mia vista si sposta quando imposto la sua cornice dopo aver cambiato il suo anchorPoint?
Successivamente, ho reimpostato il frame di uiLabel2
sul frame che ho creato con: (100,100,100,20).
Quando eseguo l'app, uiLabel1
e uiLabel2
vengono visualizzati in posizioni diverse. Perché?
UILabel *uiLabel1 = [[[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 20)] autorelease];
uiLabel1.text = @"UILabel1";
uiLabel1.layer.anchorPoint = CGPointMake(1, 1);
UILabel *uiLabel2 = [[[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 20)] autorelease];
uiLabel2.text = @"UILabel2";
uiLabel2.layer.anchorPoint = CGPointMake(1, 1);
uiLabel2.frame = CGRectMake(100, 100, 100, 20);
[self.view addSubview:uiLabel1];
[self.view addSubview:uiLabel2];
Oh! Rob! Grazie per la tua ottima e dettagliata risposta. –