I am trying to overlay two images in the accessoryView
of a UITableViewCell
like so:
UIView *accessoryView = [[UIView alloc] initWithFrame:cell.accessoryView.frame];
UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CellBG.png"]];
UIImageView *tickImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Tick.png"]];
[accessoryView addSubview:backgroundImage];
[accessoryView addSubview:tickImage];
cell.accessoryView = accessoryView;
// release stuff
Sadly, this doesn't work and the two images are lying in strange places on the screen...
Any suggestions?
The frames of the images need to be set to the bounds of the accessory view. You might also want to try setting the accessory view frame manually. Eg. CGRectMake(0,0,20,20)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.