占位字符,字体颜色设置
This commit is contained in:
@@ -246,13 +246,9 @@
|
|||||||
|
|
||||||
- (CRBoxInputView *)generateBoxInputView_placeholder
|
- (CRBoxInputView *)generateBoxInputView_placeholder
|
||||||
{
|
{
|
||||||
CRBoxInputCellProperty *cellProperty = [CRBoxInputCellProperty new];
|
|
||||||
// cellProperty
|
|
||||||
|
|
||||||
CRBoxInputView *_boxInputView = [CRBoxInputView new];
|
CRBoxInputView *_boxInputView = [CRBoxInputView new];
|
||||||
_boxInputView.ifNeedCursor = NO;
|
_boxInputView.ifNeedCursor = NO;
|
||||||
// _boxInputView.placeholderText = @"野生沙雕";
|
_boxInputView.placeholderText = @"野生沙雕";
|
||||||
_boxInputView.placeholderText = @"野生";
|
|
||||||
[_boxInputView loadAndPrepareViewWithBeginEdit:YES];
|
[_boxInputView loadAndPrepareViewWithBeginEdit:YES];
|
||||||
|
|
||||||
return _boxInputView;
|
return _boxInputView;
|
||||||
|
|||||||
@@ -74,6 +74,29 @@
|
|||||||
_valueLabel.hidden = NO;
|
_valueLabel.hidden = NO;
|
||||||
[self hideCustomSecurityView];
|
[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;
|
BOOL hasOriginValue = self.boxInputCellProperty.originValue && self.boxInputCellProperty.originValue.length > 0;
|
||||||
if (hasOriginValue) {
|
if (hasOriginValue) {
|
||||||
if (self.boxInputCellProperty.ifShowSecurity) {
|
if (self.boxInputCellProperty.ifShowSecurity) {
|
||||||
@@ -87,14 +110,19 @@
|
|||||||
}else{
|
}else{
|
||||||
_valueLabel.text = self.boxInputCellProperty.originValue;
|
_valueLabel.text = self.boxInputCellProperty.originValue;
|
||||||
}
|
}
|
||||||
|
defaultTextConfig();
|
||||||
}else{
|
}else{
|
||||||
BOOL hasPlaceholderText = self.boxInputCellProperty.placeholderText && self.boxInputCellProperty.placeholderText.length > 0;
|
BOOL hasPlaceholderText = self.boxInputCellProperty.cellPlaceholderText && self.boxInputCellProperty.cellPlaceholderText.length > 0;
|
||||||
if (hasPlaceholderText) {
|
if (hasPlaceholderText) {
|
||||||
_valueLabel.text = self.boxInputCellProperty.placeholderText;
|
_valueLabel.text = self.boxInputCellProperty.cellPlaceholderText;
|
||||||
|
placeholderTextConfig();
|
||||||
}else{
|
}else{
|
||||||
_valueLabel.text = @"";
|
_valueLabel.text = @"";
|
||||||
|
defaultTextConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Custom security view
|
#pragma mark - Custom security view
|
||||||
@@ -181,14 +209,6 @@
|
|||||||
self.layer.cornerRadius = boxInputCellProperty.cornerRadius;
|
self.layer.cornerRadius = boxInputCellProperty.cornerRadius;
|
||||||
self.layer.borderWidth = boxInputCellProperty.borderWidth;
|
self.layer.borderWidth = boxInputCellProperty.borderWidth;
|
||||||
|
|
||||||
if (boxInputCellProperty.cellFont) {
|
|
||||||
_valueLabel.font = boxInputCellProperty.cellFont;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (boxInputCellProperty.cellTextColor) {
|
|
||||||
_valueLabel.textColor = boxInputCellProperty.cellTextColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
[self valueLabelLoadData];
|
[self valueLabelLoadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,10 +155,22 @@ typedef void(^ConfigCellShadowBlock)(CALayer *layer);
|
|||||||
|
|
||||||
#pragma mark - Placeholder
|
#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;
|
self.securityType = CRBoxSecuritySymbolType;
|
||||||
|
|
||||||
// Placeholder
|
// 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
|
// Block
|
||||||
self.customSecurityViewBlock = ^UIView * _Nonnull{
|
self.customSecurityViewBlock = ^UIView * _Nonnull{
|
||||||
@@ -99,9 +101,11 @@
|
|||||||
copy.securityType = _securityType;
|
copy.securityType = _securityType;
|
||||||
|
|
||||||
// Placeholder
|
// Placeholder
|
||||||
if (_placeholderText) {
|
if (_cellPlaceholderText) {
|
||||||
copy.placeholderText = [_placeholderText copy];
|
copy.cellPlaceholderText = [_cellPlaceholderText copy];
|
||||||
}
|
}
|
||||||
|
copy.cellPlaceholderTextColor = [_cellPlaceholderTextColor copy];
|
||||||
|
copy.cellPlaceholderFont = [_cellPlaceholderFont copy];
|
||||||
|
|
||||||
// Block
|
// Block
|
||||||
copy.customSecurityViewBlock = [_customSecurityViewBlock copy];
|
copy.customSecurityViewBlock = [_customSecurityViewBlock copy];
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
|
|||||||
NSString *currentPlaceholderStr = nil;
|
NSString *currentPlaceholderStr = nil;
|
||||||
if (_placeholderText.length > indexPath.row) {
|
if (_placeholderText.length > indexPath.row) {
|
||||||
currentPlaceholderStr = [_placeholderText substringWithRange:NSMakeRange(indexPath.row, 1)];
|
currentPlaceholderStr = [_placeholderText substringWithRange:NSMakeRange(indexPath.row, 1)];
|
||||||
cellProperty.placeholderText = currentPlaceholderStr;
|
cellProperty.cellPlaceholderText = currentPlaceholderStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setOriginValue
|
// setOriginValue
|
||||||
|
|||||||
Reference in New Issue
Block a user