Add an ASEditableTextNode initializer that allows customization of its ASTextKitComponents

This commit is contained in:
Eric Jensen
2016-03-25 22:23:03 -07:00
parent f8f3585764
commit 0d52176e03
3 changed files with 22 additions and 4 deletions

View File

@@ -12,7 +12,6 @@
#import "ASDisplayNode+Subclasses.h"
#import "ASEqualityHelpers.h"
#import "ASTextKitHelpers.h"
#import "ASTextNodeWordKerner.h"
#import "ASThread.h"
@@ -93,6 +92,13 @@
#pragma mark - NSObject Overrides
- (instancetype)init
{
return [self initWithTextKitComponents:[ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero]
placeholderTextKitComponents:[ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero]];
}
- (instancetype)initWithTextKitComponents:(ASTextKitComponents *)textKitComponents
placeholderTextKitComponents:(ASTextKitComponents *)placeholderTextKitComponents
{
if (!(self = [super init]))
return nil;
@@ -101,14 +107,14 @@
_scrollEnabled = YES;
// Create the scaffolding for the text view.
_textKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero];
_textKitComponents = textKitComponents;
_textKitComponents.layoutManager.delegate = self;
_wordKerner = [[ASTextNodeWordKerner alloc] init];
_returnKeyType = UIReturnKeyDefault;
_textContainerInset = UIEdgeInsetsZero;
// Create the placeholder scaffolding.
_placeholderTextKitComponents = [ASTextKitComponents componentsWithAttributedSeedString:nil textContainerSize:CGSizeZero];
_placeholderTextKitComponents = placeholderTextKitComponents;
_placeholderTextKitComponents.layoutManager.delegate = self;
return self;