diff --git a/CustomKeyboard/View/KBStreamTextView.m b/CustomKeyboard/View/KBStreamTextView.m index 502a961..96ea75e 100644 --- a/CustomKeyboard/View/KBStreamTextView.m +++ b/CustomKeyboard/View/KBStreamTextView.m @@ -346,10 +346,28 @@ static inline NSString *KBTrimRight(NSString *s) { if (ivc) { id proxy = ivc.textDocumentProxy; if ([proxy conformsToProtocol:@protocol(UITextDocumentProxy)]) { - NSString *context = proxy.documentContextBeforeInput ?: @""; - for (NSUInteger i = 0; i < context.length; i++) { - [proxy deleteBackward]; + // 若用户把光标放在中间,需要同时删掉光标前后的内容再插入分片 + BOOL canAdjustCaret = [proxy respondsToSelector:@selector(adjustTextPositionByCharacterOffset:)]; + if (canAdjustCaret) { + NSString *contextAfter = proxy.documentContextAfterInput ?: @""; + while (contextAfter.length > 0) { + NSInteger offset = (NSInteger)contextAfter.length; + [proxy adjustTextPositionByCharacterOffset:offset]; + for (NSUInteger i = 0; i < contextAfter.length; i++) { + [proxy deleteBackward]; + } + contextAfter = proxy.documentContextAfterInput ?: @""; + } } + + NSString *contextBefore = proxy.documentContextBeforeInput ?: @""; + while (contextBefore.length > 0) { + for (NSUInteger i = 0; i < contextBefore.length; i++) { + [proxy deleteBackward]; + } + contextBefore = proxy.documentContextBeforeInput ?: @""; + } + if (rawText.length > 0) { [proxy insertText:rawText]; } diff --git a/keyBoard/Class/Guard/V/KBGuideKFCell.m b/keyBoard/Class/Guard/V/KBGuideKFCell.m index 1925e35..4f11bc6 100644 --- a/keyBoard/Class/Guard/V/KBGuideKFCell.m +++ b/keyBoard/Class/Guard/V/KBGuideKFCell.m @@ -14,8 +14,8 @@ @implementation KBGuideKFCell - (void)setupUI { - self.contentView.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0]; - + self.contentView.backgroundColor = [UIColor clearColor]; + self.backgroundColor = [UIColor clearColor]; [self.contentView addSubview:self.avatarImageView]; [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(16); diff --git a/keyBoard/Class/Guard/V/KBGuideUserCell.m b/keyBoard/Class/Guard/V/KBGuideUserCell.m index e6277cb..95d8f17 100644 --- a/keyBoard/Class/Guard/V/KBGuideUserCell.m +++ b/keyBoard/Class/Guard/V/KBGuideUserCell.m @@ -16,7 +16,9 @@ @implementation KBGuideUserCell - (void)setupUI { - self.contentView.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0]; + self.contentView.backgroundColor = [UIColor clearColor]; + self.backgroundColor = [UIColor clearColor]; + [self.contentView addSubview:self.avatarImageView]; [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { diff --git a/keyBoard/Class/Search/V/KBSearchBarView.m b/keyBoard/Class/Search/V/KBSearchBarView.m index 8b133df..c941dc3 100644 --- a/keyBoard/Class/Search/V/KBSearchBarView.m +++ b/keyBoard/Class/Search/V/KBSearchBarView.m @@ -35,8 +35,8 @@ [self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.bgView); - make.right.equalTo(self.bgView).offset(-8); - make.width.mas_greaterThanOrEqualTo(84); + make.right.equalTo(self.bgView).offset(-4); + make.width.mas_equalTo(84); make.height.mas_equalTo(32); }];