我有5个单元格的tableview。我添加了一个带故事板的UIImageView,并将这些uiimageview.image属性设置为图像。但是,我认为图像位于单元边缘右侧的几个像素(HIG之后)。如何设置图像以便从单元格的左边缘开始?
答案 0 :(得分:0)
假设您正在设置标签:
UILabel *label = [[UILabel alloc] initFrame:CGRectMake(0, 0, <width>, <height>)];
试试这个:
UILabel *label = [[UILabel alloc] initFrame:CGRectMake(-10, 0, <width>, <height>)];
答案 1 :(得分:0)
如果您在界面构建器中执行此操作,请检查单元格和图像视图的x,y属性。
或以编程方式
CGFloat width = cell.frame.size.width, height = 40;
UILabel *label = [[UILabel alloc] initFrame:CGRectMake(0, 0, width, height)];
UITextField * tf = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, width, height)];
[cell addSubView:label]
or
[cell addSubView:tf];