Skip to content
This repository was archived by the owner on Apr 22, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion class/HPGrowingTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
- (BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView;
@end

@interface HPGrowingTextView : UIView <UITextViewDelegate> {
@interface HPGrowingTextView : UIView <UITextViewDelegate, NSLayoutManagerDelegate> {
HPTextViewInternal *internalTextView;

int minHeight;
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions class/HPGrowingTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ -(void)growDidStop;
@end

@implementation HPGrowingTextView
@synthesize textLineSpacing;
@synthesize internalTextView;
@synthesize delegate;
@synthesize maxHeight;
Expand Down Expand Up @@ -114,6 +115,8 @@ -(void)commonInitialiser

[self setPlaceholderColor:[UIColor lightGrayColor]];
internalTextView.displayPlaceHolder = YES;
internalTextView.layoutManager.delegate = self;
textLineSpacing = 0.0f;
}

-(CGSize)sizeThatFits:(CGSize)size
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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