mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-06 21:22:44 +00:00
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:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user