我试图通过向右移动标签来为红色删除图标创建空间,从而使自定义UITableViewCell的内容具有动画效果。移动很好,但是整个文本被截断了,这是不应该的,我没有理由这样做,因为有足够的空间。这是它在编辑状态下的外观

这是我的代码
-(void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
if (editing) {
self.image.alpha = 0.0;
self.textLabel.frame = CGRectMake(15, 0, 30, 44);
} else {
self.image.alpha = 1.0;
self.textLabel.frame = CGRectMake(10, 0, 30, 44);
}
}我在这里做错了什么?非常感谢!
发布于 2013-06-18 16:45:12
-(void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
CGRect frame = CGRectZero;
if (editing) {
self.image.alpha = 0.0;
frame.origin = CGPointMake(15, 0);
} else {
self.image.alpha = 1.0;
frame.origin = CGPointMake(10, 0);
}
frame.size = [self.textLabel.text sizeWithFont:self.textLabel.font];
self.textLabel.frame = frame;
}发布于 2013-06-18 16:35:25
尝试使用以下命令:
self.textLabel.numberOfLines = 0;
[self.textLabel sizeToFit];或者你可以试试这个:
self.textLabel.center = CGPointMake(self.textLabel.center.x + 5, self.textLabel.center.y);或者你可以试试这个:
self.textLabel.frame = CGRectMake(self.textLabel.origin.x + 5, self.textLabel.origin.y, self.textLabel.bounds.size.width, self.textLabel.bounds.size.height);或者你可以试试这个:
CGSize textSize = [self.textLabel.text sizeWithFont:self.textLabel.font constrainedToSize:self.textLabel.bounds.size lineBreakMode:self.textLabel.lineBreakMode];
self.textLabel.frame = CGRectMake(self.textLabel.origin.x + 5, self.textLabel.origin.y, self.textLabel.bounds.size.width, textSize.height);https://stackoverflow.com/questions/17164071
复制相似问题