既存のアプリXcode6で実行した
UILabel *label1 = [[UILabel alloc]initWithFrame:self.view.frame];
label1.backgroundColor = [UIColor whitecolor];
UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(0,0,100,100)];
label2.backgroundColor = [UIColor redcolor];
[label1 addSubView:label2];
[self addSubview:label1];
label1のみが表示されるように見えるが、実際は、backgroundColorの色で塗りつぶされていた。
対応策1
UILabel *label1 = [[UILabel alloc]initWithFrame:self.view.frame];
label1.backgroundColor = [UIColor whitecolor];
UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(0,0,100,100)];
label2.backgroundColor = [UIColor redcolor];
[label1 insertSubView:label2 atIndex:0];
[self addSubview:label1];
変わらず
対応策2
UILabel *label1 = [[UILabel alloc]initWithFrame:self.view.frame];
label1.backgroundColor = [UIColor whitecolor];
UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(0,0,100,100)];
label2.backgroundColor = [UIColor redcolor];
[label1.superview insertSubview:label2 belowSubview:blabel];
[self addSubview:label1];
blabel表示されず
対応策3
UILabel *label1 = [[UILabel alloc]initWithFrame:self.view.frame];
label1.layer.backgroundColor = [UIColor whitecolor].CGColor;
UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(0,0,100,100)];
label2.backgroundColor = [UIColor redcolor];
[label1 addSubView:label2];
[self addSubview:label1];
ios7と同じ見た目になった。
あとがき
UILabelの挙動が変わっていて、つまずきました。
新規でProjectを作成すると、今までどおりで表示されていたので、意味不明でした。
同じ症状の人の為に、メモしておきます。
くわしい方は、ぜひ原因を教えてください。