Align UITableViewCell accessory for bottom of cell instead of middle

In the Native Mail application, the To: field on the right side of the accessory item has a ContactAdd UIButton link, but it is aligned to the bottom of the cell (which you can see as the cell grows). Is it possible to simulate this using the accessoriesView property? As far as I can tell, accessory elements are always aligned in the middle.

+3
source share
2 answers

I found that you can subclass UITableViewCell, override layoutSubviews and in this method get an accessory and configure its frame as desired.

+7
source

In my application, I found a partially working solution with the following code:

UIImage *accessoryImage = [UIImage imageNamed:@"accessory_disclosure_bottom.png"];
UIImageView *accImageView = [[UIImageView alloc] initWithImage:accessoryImage];
[accImageView setFrame:CGRectMake(0, 10, 14, 28)];
accImageView.backgroundColor = [UIColor greenColor];
accImageView.userInteractionEnabled = YES;
cell.accessoryView = accImageView;

http://m.tech-recipes.com/rx/UITV_accessory_disclosure.png, . , , (, , ).

+1

Source: https://habr.com/ru/post/1741693/


All Articles