tag屬性是一個(gè)快捷取視圖的方法,需要先對(duì)視圖設(shè)置tag屬性轨域,然后就能通過viewWithTag:方法來取用凛虽;
UIView *aView = [[UIView alloc] init];
aView.tag = 101;
[self.window addSubview:aView];
[aView release];
[self.window viewWithTag:101].backgroundColor = [UIColor redColor];
tag屬性在對(duì)象創(chuàng)建之后就可以設(shè)置庄新,但是要取用它隅茎,必須先將這個(gè)視圖放入其父視圖的數(shù)組中澄峰;
viewWithTag可以取用所有子視圖組以及子視圖的子視圖組
#define kGetView(tag) [self.view viewWithTag:tag]