I'm using a UIImageView as the accessoryView in a UITableViewCell that I'm creating programmatically. I've tried everything I can think of to set the accessoryView's alpha property, but it's not working. I'm able to set the hidden and opaque properties with no problems, but alpha is hating all over me.
I tried creating a new project that contains a single UITableViewController and the following tableView:cellForRowAtIndexPath: method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"Cell";
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
cell.accessoryView = iv;
[iv release];
// cell.accessoryView.hidden = YES; // works
cell.accessoryView.alpha = 0.5f; // fails
return cell;
}
As you may have guessed, the accessoryView is fully opaque. Am I missing something? I can't find any information about what's going on here.
Thanks!
The view to use on the right side of the cell, typically as a control, in the table view's normal state. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.0+ tvOS 9.0+
After trying about a billion different things and looking everywhere for some answers, I ended up just faking it by adding a subview to the cell's contentView and positioning it to the accessory position. I'm able to set the alpha property on that subview to my heart's content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With