我正在尝试使用带有vibrancyEffect的文本标签在我的UITableView中创建一个模糊的标题,但是我得到的这个代码是一个没有任何文本标签的模糊标题... 怎么了? :)
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
// Header Background color
view.tintColor = [UIColor clearColor];
// header Text Color
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
[header.textLabel setTextColor:[UIColor clearColor]];
//Header blur
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *visualEffectView;
visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = header.bounds;
[header addSubview:visualEffectView];
// Text vibrancyEffect
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
vibrancyEffectView.frame=header.textLabel.frame;
[vibrancyEffectView.contentView addSubview:header.textLabel];
[visualEffectView.contentView addSubview:vibrancyEffectView];
}
提前致谢!
答案 0 :(得分:0)
这已经晚了......但你将文字设置为清晰的颜色。你有什么期望这样做? :)
header.textLabel setTextColor:[UIColor clearColor]];
无论如何,我的建议是尝试这样的事情:
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
[header.textLabel setTextColor:[UIColor whiteColor]];
header.textLabel.backgroundColor = [UIColor clearColor];
//making background clear, and then placing a blur view across the entire header (execpt the uilabel)
UIVisualEffectView *blurEffectView;
view.tintColor = [UIColor clearColor];
blurEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
blurEffectView.frame = view.bounds;
blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[view addSubview:blurEffectView];
[view bringSubviewToFront:header.textLabel];
[view sendSubviewToBack:blurEffectView];