2011-07-29 46 views
0

我想在ContainerView中使用UILabel。
所以我使用這個代碼。ContainerView隱藏UILabel

UILabel *myLabel = [[[UILabel alloc] initWithFrame:CGRectMake(16, 60, 300, 150)] autorelease]; 
myLabel.numberOfLines = 0; 
myLabel.font = [UIFont systemFontOfSize:13.5]; 
myLabel.text = [theQuiz objectAtIndex:row+3] ; 
myLabel.lineBreakMode = UILineBreakModeWordWrap; 
myLabel.backgroundColor = [UIColor clearColor]; 
myLabel.layer.cornerRadius = 8.0; 
[myLabel sizeToFit]; 
[self.view addSubview:myLabel]; 

//ContainerView 
UIView *ChallengeView = [[UIView alloc] initWithFrame:CGRectMake(8, 55, 300, 10 + Challenge.frame.size.height)]; 
ChallengeView.layer.borderColor = [[UIColor purpleColor ] CGColor]; 
[ChallengeView setBackgroundColor:[UIColor whiteColor]]; 
ChallengeView.layer.cornerRadius = 8 ; 
ChallengeView.layer.borderWidth = 1.5; 
[self.view addSubview:ChallengeView]; 
[ChallengeView release]; 

現在的問題是,當我爲ContainerView設置背景色它隱藏myLabel

任何解決方案的文本?

回答

0

正在發生的事情是被添加上面的標籤你containerView要麼你containerView之後添加標籤或做到這一點:

[self.view bringSubviewToFront:myLabel]; 
+0

它的工作..! 謝謝xs2bush .. :) – iUser

0

先添加ChallengeView,然後添加myLabel。 否則u能做到像@ xs2bush說,

[self.view bringSubviewToFront:myLabel]; 

BCZ的ChallengeView隱藏的標籤。

+0

我明白了.. :) Thanx EXC_ .. !! – iUser