Objective c 如何隐藏图像
我想知道你如何在Objective-C中隐藏图像。 我知道你可以隐藏这样的文本或按钮Objective c 如何隐藏图像,objective-c,ios7,Objective C,Ios7,我想知道你如何在Objective-C中隐藏图像。 我知道你可以隐藏这样的文本或按钮 StartGame.hidden = YES; 但是,当我尝试对图像执行此操作时,会出现错误 UIImageView *ImageView=[[UIImageView alloc] initWithFrame:CGRectMake(x, y,width, height)]; [ImageView setImage:[UIImage imageNamed:@"image.png"]]; 要隐
StartGame.hidden = YES;
但是,当我尝试对图像执行此操作时,会出现错误
UIImageView *ImageView=[[UIImageView alloc] initWithFrame:CGRectMake(x, y,width, height)];
[ImageView setImage:[UIImage imageNamed:@"image.png"]];
要隐藏这个图像,你只需要写
[ImageView setHidden:YES];
由于
UILabel
,UIButton
,并且都是来自的孩子,因此它们都具有隐藏它们的属性
因此,通过将hidden属性设置为YES
,可以隐藏视图(或其子视图)的任何实例
如果您的是viewcontroller的一部分,那么将其设置为属性而不仅仅是变量是有意义的,但是我看不到您的完整代码或错误,无法说明可能在那里找到了错误
此外,属性或变量不应以大写字母开头,这与Objective-C样式不一致。要隐藏UIImageview以保留UIImages。例如,UIImageview*imgView=[[UIImageview alloc]initWithImage:[uiImageName:@“ing.png”];然后使用imgView.hidden=YES,这将隐藏图像。您可以显示错误吗?谢谢您的帮助:)