占位字符,字体颜色设置
This commit is contained in:
@@ -246,13 +246,9 @@
|
||||
|
||||
- (CRBoxInputView *)generateBoxInputView_placeholder
|
||||
{
|
||||
CRBoxInputCellProperty *cellProperty = [CRBoxInputCellProperty new];
|
||||
// cellProperty
|
||||
|
||||
CRBoxInputView *_boxInputView = [CRBoxInputView new];
|
||||
_boxInputView.ifNeedCursor = NO;
|
||||
// _boxInputView.placeholderText = @"野生沙雕";
|
||||
_boxInputView.placeholderText = @"野生";
|
||||
_boxInputView.placeholderText = @"野生沙雕";
|
||||
[_boxInputView loadAndPrepareViewWithBeginEdit:YES];
|
||||
|
||||
return _boxInputView;
|
||||
|
||||
@@ -74,6 +74,29 @@
|
||||
_valueLabel.hidden = NO;
|
||||
[self hideCustomSecurityView];
|
||||
|
||||
// 默认字体配置
|
||||
__weak typeof(self) weakSelf = self;
|
||||
void (^defaultTextConfig)(void) = ^{
|
||||
if (weakSelf.boxInputCellProperty.cellFont) {
|
||||
weakSelf.valueLabel.font = weakSelf.boxInputCellProperty.cellFont;
|
||||
}
|
||||
|
||||
if (weakSelf.boxInputCellProperty.cellTextColor) {
|
||||
weakSelf.valueLabel.textColor = weakSelf.boxInputCellProperty.cellTextColor;
|
||||
}
|
||||
};
|
||||
|
||||
// 占位字符字体配置
|
||||
void (^placeholderTextConfig)(void) = ^{
|
||||
if (weakSelf.boxInputCellProperty.cellFont) {
|
||||
weakSelf.valueLabel.font = weakSelf.boxInputCellProperty.cellPlaceholderFont;
|
||||
}
|
||||
|
||||
if (weakSelf.boxInputCellProperty.cellTextColor) {
|
||||
weakSelf.valueLabel.textColor = weakSelf.boxInputCellProperty.cellPlaceholderTextColor;
|
||||
}
|
||||
};
|
||||
|
||||
BOOL hasOriginValue = self.boxInputCellProperty.originValue && self.boxInputCellProperty.originValue.length > 0;
|
||||
if (hasOriginValue) {
|
||||
if (self.boxInputCellProperty.ifShowSecurity) {
|
||||
@@ -87,14 +110,19 @@
|
||||
}else{
|
||||
_valueLabel.text = self.boxInputCellProperty.originValue;
|
||||
}
|
||||
defaultTextConfig();
|
||||
}else{
|
||||
BOOL hasPlaceholderText = self.boxInputCellProperty.placeholderText && self.boxInputCellProperty.placeholderText.length > 0;
|
||||
BOOL hasPlaceholderText = self.boxInputCellProperty.cellPlaceholderText && self.boxInputCellProperty.cellPlaceholderText.length > 0;
|
||||
if (hasPlaceholderText) {
|
||||
_valueLabel.text = self.boxInputCellProperty.placeholderText;
|
||||
_valueLabel.text = self.boxInputCellProperty.cellPlaceholderText;
|
||||
placeholderTextConfig();
|
||||
}else{
|
||||
_valueLabel.text = @"";
|
||||
defaultTextConfig();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Custom security view
|
||||
@@ -181,14 +209,6 @@
|
||||
self.layer.cornerRadius = boxInputCellProperty.cornerRadius;
|
||||
self.layer.borderWidth = boxInputCellProperty.borderWidth;
|
||||
|
||||
if (boxInputCellProperty.cellFont) {
|
||||
_valueLabel.font = boxInputCellProperty.cellFont;
|
||||
}
|
||||
|
||||
if (boxInputCellProperty.cellTextColor) {
|
||||
_valueLabel.textColor = boxInputCellProperty.cellTextColor;
|
||||
}
|
||||
|
||||
[self valueLabelLoadData];
|
||||
}
|
||||
|
||||
|
||||
@@ -155,10 +155,22 @@ typedef void(^ConfigCellShadowBlock)(CALayer *layer);
|
||||
|
||||
#pragma mark - Placeholder
|
||||
/**
|
||||
默认填充值
|
||||
占位符默认填充值
|
||||
禁止修改该值!!!(除非你知道该怎么使用它。)
|
||||
*/
|
||||
@property (strong, nonatomic) NSString *placeholderText;
|
||||
@property (strong, nonatomic) NSString *__nullable cellPlaceholderText;
|
||||
|
||||
/**
|
||||
占位符字体颜色
|
||||
默认:[UIColor colorWithRed:114/255.0 green:126/255.0 blue:124/255.0 alpha:0.3];
|
||||
*/
|
||||
@property (copy, nonatomic) UIColor *cellPlaceholderTextColor;
|
||||
|
||||
/**
|
||||
占位符字体/字号
|
||||
默认:[UIFont systemFontOfSize:20];
|
||||
*/
|
||||
@property (copy, nonatomic) UIFont *cellPlaceholderFont;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@
|
||||
self.securityType = CRBoxSecuritySymbolType;
|
||||
|
||||
// Placeholder
|
||||
self.placeholderText = nil;
|
||||
self.cellPlaceholderText = nil;
|
||||
self.cellPlaceholderTextColor = [UIColor colorWithRed:114/255.0 green:116/255.0 blue:124/255.0 alpha:0.3];
|
||||
self.cellPlaceholderFont = [UIFont systemFontOfSize:20];
|
||||
|
||||
// Block
|
||||
self.customSecurityViewBlock = ^UIView * _Nonnull{
|
||||
@@ -99,9 +101,11 @@
|
||||
copy.securityType = _securityType;
|
||||
|
||||
// Placeholder
|
||||
if (_placeholderText) {
|
||||
copy.placeholderText = [_placeholderText copy];
|
||||
if (_cellPlaceholderText) {
|
||||
copy.cellPlaceholderText = [_cellPlaceholderText copy];
|
||||
}
|
||||
copy.cellPlaceholderTextColor = [_cellPlaceholderTextColor copy];
|
||||
copy.cellPlaceholderFont = [_cellPlaceholderFont copy];
|
||||
|
||||
// Block
|
||||
copy.customSecurityViewBlock = [_customSecurityViewBlock copy];
|
||||
|
||||
@@ -309,7 +309,7 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
|
||||
NSString *currentPlaceholderStr = nil;
|
||||
if (_placeholderText.length > indexPath.row) {
|
||||
currentPlaceholderStr = [_placeholderText substringWithRange:NSMakeRange(indexPath.row, 1)];
|
||||
cellProperty.placeholderText = currentPlaceholderStr;
|
||||
cellProperty.cellPlaceholderText = currentPlaceholderStr;
|
||||
}
|
||||
|
||||
// setOriginValue
|
||||
|
||||
Reference in New Issue
Block a user