2014-10-14 2 views
0

Я пытаюсь создать яркий заголовок в моем UITableView с текстовой меткой, которая имеет эффект vibrancyEffect, но с этим кодом все, что я получаю, является размытым заголовком без каких-либо текстовых меток. Что случилось? :)Невозможно использовать UIVibrancyEffect с текстовой меткой заголовка tableView

- (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

Это уже поздно ... но вы установили текст в четкий цвет. Что вы ожидали от этого? :)

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];