【发布时间】:2014-05-15 10:53:58
【问题描述】:
单击UIButton 时,我会创建一个UIView 并将其放在前面。我将它的“alpha=0.6”设置为显示半透明,然后我添加了各种“子视图”。不知何故,这些“子视图”也显示了我不想要的半透明。谢谢!
- (IBAction)OnClickTutorialGuideButton:(id)sender
{
dimView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];
dimView.backgroundColor = [UIColor blackColor];
dimView.alpha = 0.4;
[self.view addSubview:dimView];
[self.view bringSubviewToFront:dimView];
[UIView animateWithDuration:0.3
animations:^{
dimView.alpha = 0.6;
}];
// Label
UILabel *getStartedLabel=[[UILabel alloc]initWithFrame:CGRectMake(72, 50, 176, 25)];
getStartedLabel.text=@"Getting Started";
getStartedLabel.textColor=[UIColor colorWithRed:(243.0/255.0) green:(107.0/255.0) blue:(55.0/255.0) alpha:1.0];
getStartedLabel.font=[UIFont boldSystemFontOfSize:25.0f];
[dimView addSubview:getStartedLabel];
// ImageView
UIImageView *remImage=[[UIImageView alloc]initWithFrame:CGRectMake(68, 90, 180, 180)];
remImage.image=[UIImage imageNamed:@"getting_started1_large_icon.png"];
[dimView addSubview:remImage];
}
a) 之前:
b) 之后:
【问题讨论】:
标签: ios objective-c uiview transparency