简体   繁体   English

UITableViewCell的accessoryView中的多个视图

[英]Multiple Views in accessoryView of UITableViewCell

I am trying to overlay two images in the accessoryView of a UITableViewCell like so: 我想在叠加两个图像accessoryView一个中UITableViewCell ,像这样:

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) CGRectMake(0,0,20,20)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM