的中心我一直在使用这个移动标签细胞
UILabel *label1 = (UILabel *) [cell viewWithTag:1];
我想我的标签移动到细胞的中心...... 任何一个可以回答这个问题建立了我的标签.... 谢谢对于有价值的答案...
的中心我一直在使用这个移动标签细胞
UILabel *label1 = (UILabel *) [cell viewWithTag:1];
我想我的标签移动到细胞的中心...... 任何一个可以回答这个问题建立了我的标签.... 谢谢对于有价值的答案...
刚才设置的标签帧到合适的偏移:
x=cell.frame.width/2-label1.frame.width/2;
y=cell.frame.height/2-label1.frame.height/2;
label1.frame=CGRectMake(x,y,cell.frame.width,cell.frame.height);
单元格的中心点是在cell.superview坐标,只是转换THA t指向单元格的坐标并在此处设置标签的中心:
label1.center = [cell.superview convertPoint:cell.center toView:cell];
下面的代码向集合视图单元格的中心添加一个标签。
// self is the current cell.
UILabel *pointLabel = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
pointLabel.textAlignment = NSTextAlignmentCenter;
pointLabel.textColor = [UIColor yellowColor];
pointLabel.text = @"+300";
[self addSubview:pointLabel];
希望这会有所帮助。