diff --git a/class/HPGrowingTextView.h b/class/HPGrowingTextView.h index 8b343c5..af74f53 100644 --- a/class/HPGrowingTextView.h +++ b/class/HPGrowingTextView.h @@ -55,7 +55,7 @@ - (BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView; @end -@interface HPGrowingTextView : UIView { +@interface HPGrowingTextView : UIView { HPTextViewInternal *internalTextView; int minHeight; @@ -90,6 +90,7 @@ @property (nonatomic, strong) NSString *placeholder; @property (nonatomic, strong) UIColor *placeholderColor; @property (nonatomic, strong) UITextView *internalTextView; +@property (nonatomic) CGFloat textLineSpacing; //uitextview properties diff --git a/class/HPGrowingTextView.m b/class/HPGrowingTextView.m index e7f5dbb..33dc4e0 100644 --- a/class/HPGrowingTextView.m +++ b/class/HPGrowingTextView.m @@ -35,6 +35,7 @@ -(void)growDidStop; @end @implementation HPGrowingTextView +@synthesize textLineSpacing; @synthesize internalTextView; @synthesize delegate; @synthesize maxHeight; @@ -114,6 +115,8 @@ -(void)commonInitialiser [self setPlaceholderColor:[UIColor lightGrayColor]]; internalTextView.displayPlaceHolder = YES; + internalTextView.layoutManager.delegate = self; + textLineSpacing = 0.0f; } -(CGSize)sizeThatFits:(CGSize)size @@ -241,6 +244,17 @@ - (void)setPlaceholder:(NSString *)placeholder [internalTextView setNeedsDisplay]; } +- (CGFloat)textLineSpacing +{ + return self.textLineSpacing; +} + +- (void)setTextLineSpacing:(CGFloat)lineSpacing +{ + textLineSpacing = lineSpacing; + [internalTextView setNeedsDisplay]; +} + - (UIColor *)placeholderColor { return internalTextView.placeholderColor; @@ -691,6 +705,12 @@ - (void)textViewDidChangeSelection:(UITextView *)textView { } } +/////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark - NSLayoutManagerDelegate +- (CGFloat)layoutManager:(NSLayoutManager *)layoutManager lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(CGRect)rect { + return self.textLineSpacing; +} @end