Skip to content

Commit d8b580c

Browse files
committed
_placeholderLabel.textColor
1 parent 6577391 commit d8b580c

3 files changed

Lines changed: 3 additions & 8 deletions

File tree

Coding_iOS/Controllers/EditTopicViewController.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,7 @@ - (void)loadEditView{
172172
&& (![title isEqualToString:self.curProTopic.mdTitle] || ![content isEqualToString:self.curProTopic.mdContent]));
173173
return @(enabled);
174174
}];
175-
_inputTitleView.placeholder = self.type == TopicEditTypeFeedBack? @"反馈标题": @"讨论标题";
176-
[_inputTitleView setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
177-
_inputContentView.placeholder = self.type == TopicEditTypeFeedBack? @"反馈内容": @"讨论内容";
178-
175+
_inputTitleView.attributedPlaceholder = [[NSAttributedString alloc] initWithString:(self.type == TopicEditTypeFeedBack? @"反馈标题": @"讨论标题") attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}];
179176
_inputTitleView.text = _curProTopic.mdTitle;
180177
_inputContentView.text = _curProTopic.mdContent;
181178
}

Coding_iOS/Views/Cell/InputOnlyTextPlainCell.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
2323
self.selectionStyle = UITableViewCellSelectionStyleNone;
2424
if (!_textField) {
2525
_textField = [[UITextField alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 7.0, kScreen_Width-kPaddingLeftWidth*2, 30)];
26-
[_textField setValue:[UIColor colorWithHexString:@"0x999999"] forKeyPath:@"_placeholderLabel.textColor"];//修改placeholder颜色
2726
_textField.backgroundColor = [UIColor clearColor];
2827
_textField.borderStyle = UITextBorderStyleNone;
2928
_textField.font = [UIFont systemFontOfSize:16];
@@ -37,7 +36,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
3736

3837
- (void)layoutSubviews{
3938
[super layoutSubviews];
40-
_textField.placeholder = _phStr;
39+
_textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:_phStr? _phStr: @"" attributes:@{NSForegroundColorAttributeName: [UIColor colorWithHexString:@"0x999999"]}];
4140
_textField.text = _valueStr;
4241
_textField.secureTextEntry = _isSecure;
4342
}

Coding_iOS/Views/Cell/Input_OnlyText_Cell.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ - (IBAction)editDidEnd:(id)sender {
4242
}
4343

4444
- (void)configWithPlaceholder:(NSString *)phStr andValue:(NSString *)valueStr{
45-
self.textField.placeholder = phStr;
45+
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:phStr? phStr: @"" attributes:@{NSForegroundColorAttributeName: [UIColor colorWithHexString:_isForLoginVC? @"0xffffff": @"0x999999" andAlpha:_isForLoginVC? 0.5: 1.0]}];
4646
self.textField.text = valueStr;
4747
}
4848
- (IBAction)textValueChanged:(id)sender {
@@ -63,7 +63,6 @@ - (void)layoutSubviews {
6363
self.backgroundColor = _isForLoginVC? [UIColor clearColor]: [UIColor whiteColor];
6464
self.textField.font = [UIFont systemFontOfSize:17];
6565
self.textField.textColor = _isForLoginVC? [UIColor whiteColor]: [UIColor colorWithHexString:@"0x222222"];
66-
[self.textField setValue:[UIColor colorWithHexString:_isForLoginVC? @"0xffffff": @"0x999999" andAlpha:_isForLoginVC? 0.5: 1.0] forKeyPath:@"_placeholderLabel.textColor"];//修改placeholder颜色
6766
if (!_lineView && _isForLoginVC) {
6867
_lineView = [[UIView alloc] initWithFrame:CGRectMake(kLoginPaddingLeftWidth, 43.5, kScreen_Width-2*kLoginPaddingLeftWidth, 0.5)];
6968
_lineView.backgroundColor = [UIColor colorWithHexString:@"0xffffff" andAlpha:0.5];

0 commit comments

Comments
 (0)