我注意到在移动领域中插入x,y坐标是一个危险的主意。我的x,y坐标在4s和5s上看起来不错,但在6s上看起来很不错。我的居中位置非常接近,但还没有完全确定。有人可以帮助我了解我在做什么错吗?谢谢!
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
float imgWidth = 100;
float imgHeight = 80;
self.showImage = [[UIImageView alloc]initWithFrame:CGRectMake((self.contentView.bounds.size.width/2)-(imgWidth/2),15,imgWidth,imgHeight)];
[self.contentView addSubview:self.showImage];
;
}
return self;
}
iPhone 4S和iPhone 5S的宽度相同(320磅)。iPhone 6的宽度为375点,iPhone 6+的宽度为414点。因此,如果您没有同时为iPhone 6和iPhone 6+使用应用程序的缩放版本,则无法手动设置框架并期望它们正确居中。
快速/肮脏选项:
[UIScreen mainScreen].bounds.size.width
并相应地手动更改框架更好的选择:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句