diff --git a/AsyncDisplayKit/ASEditableTextNode.h b/AsyncDisplayKit/ASEditableTextNode.h index 0581cfe638..ee20ce808a 100644 --- a/AsyncDisplayKit/ASEditableTextNode.h +++ b/AsyncDisplayKit/ASEditableTextNode.h @@ -59,6 +59,11 @@ //! @abstract The text input mode used by the receiver's keyboard, if it is visible. This value is undefined if the receiver is not the first responder. @property (nonatomic, readonly) UITextInputMode *textInputMode; +/* + @abstract The textContainerInset of both the placeholder and typed textView. This value defaults to UIEdgeInsetsZero. + */ +@property (nonatomic, readwrite) UIEdgeInsets textContainerInset; + /* @abstract The returnKeyType of the keyboard. This value defaults to UIReturnKeyDefault. */ diff --git a/AsyncDisplayKit/ASEditableTextNode.mm b/AsyncDisplayKit/ASEditableTextNode.mm index 5b929ccfb3..b0beb67385 100644 --- a/AsyncDisplayKit/ASEditableTextNode.mm +++ b/AsyncDisplayKit/ASEditableTextNode.mm @@ -78,7 +78,8 @@ _textKitComponents.layoutManager.delegate = self; _wordKerner = [[ASTextNodeWordKerner alloc] init]; _returnKeyType = UIReturnKeyDefault; - + _textContainerInset = UIEdgeInsetsZero; + // Create the placeholder scaffolding. _placeholderTextKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero]; _placeholderTextKitComponents.layoutManager.delegate = self; @@ -122,7 +123,7 @@ textView.backgroundColor = nil; textView.opaque = NO; } - textView.textContainerInset = UIEdgeInsetsZero; + textView.textContainerInset = self.textContainerInset; textView.clipsToBounds = NO; // We don't want selection handles cut off. }; @@ -175,6 +176,15 @@ _placeholderTextKitComponents.textView.backgroundColor = backgroundColor; } +- (void)setTextContainerInset:(UIEdgeInsets)textContainerInset +{ + ASDN::MutexLocker l(_textKitLock); + + _textContainerInset = textContainerInset; + _textKitComponents.textView.textContainerInset = textContainerInset; + _placeholderTextKitComponents.textView.textContainerInset = textContainerInset; +} + - (void)setOpaque:(BOOL)opaque { [super setOpaque:opaque];