我編寫了一個UILabel
並觸發了一個按鈕,我想隱藏相同的標籤。這是我的代碼:創建並隱藏UILabel
UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 320, 100)];
nameLabel.text = @"TEXT";
nameLabel.backgroundColor = [UIColor greenColor];
nameLabel.numberOfLines = 5;
nameLabel.font = [UIFont boldSystemFontOfSize:12];
[self.view addSubview:nameLabel];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Hide" style:UIBarButtonItemStyleBordered target:self action:@selector(back)];
- (IBAction)back{
self.navigationItem.rightBarButtonItem=nil;
[nameLabel setHidden: YES]; not working
nameLabel.hidden = YES; not working
}
我錯過了什麼嗎?
謝謝you..I我編程很新。你能解釋一下我在做什麼? nameLabel.tag = 1001;非常感謝你 – Mitch1972
這條線給這個標籤標籤。標籤是視圖中物品的標識。您可以通過他們的標籤號訪問項目。 –