2017-02-01 19 views
1

UITextViewUITableViewCellです。私はUITableView内のUITextViewは余分なパディングを削除します

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; 
     } 
    } 

の内側にそれの制約を設定しています。しかし、結果は私が上下に余分な画素を有するenter image description here

です。私はそれを削除したい。私が何をしたか:

1)self.automaticallyAdjustsScrollViewInsets = NO;を)私のUIViewController

2に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; 
} 

のサブクラスでは、私はUIEdgeInsetsMake(-4, -5, 0, 0);テキストがトップに移動しますが、一番下の余分なスペースがまだ

が存在する場合

お願いします。

答えて

0

UIEdgeInsetsMake(-4、-5、0、0)を設定した場合。テキストがトップに移動しますが、一番下の余分なスペースはまだ

  • UIEdgeInsetsMake(CGFloatトップ、CGFloatは左、CGFloat底、CGFloat右)

ですからUIEdgeInsetsMake(-4、0を試すことができますが存在します、-5、0)を使用します。あなたは単語の間のスペースを削除したい場合はスペースの

0

使用この

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

THIS

NSString *newString = [yourString stringByReplacingOccurrencesOfString:@" " withString:@""]; 
をお試しください
関連する問題