UITableViewCell内的UITextView删除额外的填充

时间:2017-02-01 17:11:46

标签: ios objective-c uitableview uitextview ios-autolayout

我在categories table内有一个UITextView。我在

中设置了它的约束
UITableViewCell

但结果是enter image description here

我的顶部和底部有额外的像素。我想删除它。我做了什么:

1)我if ([keyPath isEqualToString:@"noteTextView.text"]) { [self setExcludedPaths]; if (self.noteTextView.text.length > 0) { CGSize sizeThatFitsTextView = [self.noteTextView sizeThatFits:CGSizeMake(self.noteTextView.frame.size.width, MAXFLOAT)]; self.noteTextViewHeightConstraint.constant = sizeThatFitsTextView.height; } else { self.noteTextViewHeightConstraint.constant = 0.f; } }

中的self.automaticallyAdjustsScrollViewInsets = NO;

2)在UIViewController

的子类中
UITextView

如果我将- (void)awakeFromNib { [super awakeFromNib]; self.font = [UIFont fontWithName:@"HelveticaNeue" size:16.f]; self.textColor = [UIColor noteTextColor]; self.textContainerInset = UIEdgeInsetsZero; //self.contentMode = UIViewContentModeTop; self.contentInset = UIEdgeInsetsMake(0, -5, 0, 0); self.backgroundColor = [UIColor redColor]; self.scrollEnabled = NO; } 文字移到顶部,但底部的额外空格仍然存在

请帮帮我。

2 个答案:

答案 0 :(得分:0)

如果我设置UIEdgeInsetsMake(-4,-5,0,0);文本移到顶部,但底部的额外空间仍然存在

  • UIEdgeInsetsMake(CGFloat top,CGFloat left,CGFloat bottom,CGFloat right)

所以你可以试试UIEdgeInsetsMake(-4,0,-5,0)。

答案 1 :(得分:0)

将此用于空间

yourTextField.layer.sublayerTransform = CATransform3DMakeTranslation(35, 0, 0);

如果您想删除字词之间的空格

尝试

NSString *newString = [yourString stringByReplacingOccurrencesOfString:@" " withString:@""];