需求:設(shè)置UITableView的Footer視圖透明
1. 無用:
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithReuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
self.tintColor = [UIColor clearColor];
}
return self;
}
其實(shí)咸作,上述的方法可以將視圖背景改成非透明色,比如紅色们豌。但改成透明的時候涯捻,還是會顯示灰色,不是真正的透明望迎。
2. 有用:
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithReuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
// self.tintColor = [UIColor clearColor];
// self.backgroundView.backgroundColor = [UIColor clearColor];
self.backgroundView = [UIImageView new];
self.backgroundView.alpha = 0;
}
return self;
}
上述的方法是拐個彎曲線救國的方式實(shí)現(xiàn)障癌,經(jīng)驗(yàn)證是有效的。
3. 提醒
每個人的情況可能不太一樣擂煞,筆者這里的驗(yàn)證結(jié)果可能只針對特定情況混弥,讀者自行根據(jù)實(shí)際情況參考和判斷。也可以在評論區(qū)留言寫下你工程背景和驗(yàn)證情況。