I'm using a table for showing a book catalog to the user. Some books are free others are premium books. I want to inform the user, based on their account status (free or premium), the books that they can download. Still, the user can check all books (cover and summary but not download).
For that purpose, I'm trying to dim cells that contain premium books for free users.
How can I dim cells? I have already tried previous answers like How do I make a UITableViewCell appear disabled? and UITableview: How to Disable Selection for Some Rows but Not Others but no luck. Why is alpha not working?
My tries have gone in this direction with no result:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"SelectBookCell";
SelectBookCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[SelectBookCell alloc] init];
}
// Config images, title, author... information to show
Do stuff
// Dimmed premium books
if([[userAccount level] intValue] <= (NSInteger)[book objectForKey:@"level"])
{
[cell setAlpha: 0.2f];
cell.textLabel.alpha = 0.2f;
cell.detailTextLabel.alpha = 0.2f;
}
return cell;
}