Make textContainerInset configurable for ASEditableTextNode placeholder and typed textViews

Previously, it was only possible to configure the textContainerInset of the typed textView by accessing the textView property on didLoad. This would cause the placeholder and typed textViews to become desynced however, so in this commit we add the ability to configure both.
This commit is contained in:
Samuel Hsiung
2015-10-29 16:03:06 -07:00
parent e11007f906
commit e4d2551384
2 changed files with 17 additions and 2 deletions

View File

@@ -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.
*/

View File

@@ -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];