Ios 如何在MDCTextField上设置插入符号光标颜色?
我使用的是Ios 如何在MDCTextField上设置插入符号光标颜色?,ios,material-components,Ios,Material Components,我使用的是mdctextributcontrollerfilled,设置activeColor属性会更改下划线和浮动占位符。但是,我找不到设置闪烁光标颜色的方法,默认为蓝色。 是否有更改颜色的方法?由于是UITextField的子类,您应该更改tintColor属性以更改光标的颜色: mdcTextField.tintColor = .red 由于是UITextField的子类,因此应更改tintColor属性以更改光标的颜色: mdcTextField.tintColor = .red 试
mdctextributcontrollerfilled
,设置activeColor
属性会更改下划线和浮动占位符。但是,我找不到设置闪烁光标颜色的方法,默认为蓝色。
是否有更改颜色的方法?由于是UITextField
的子类,您应该更改tintColor
属性以更改光标的颜色:
mdcTextField.tintColor = .red
由于是UITextField
的子类,因此应更改tintColor
属性以更改光标的颜色:
mdcTextField.tintColor = .red
试试这个
override func viewDidLoad() {
super.viewDidLoad()
textfield.tintColor = .red
}
试试这个
override func viewDidLoad() {
super.viewDidLoad()
textfield.tintColor = .red
}
我也遇到了同样的问题,通过子类化MDCTextField并覆盖layoutSubviews来解决这个问题,以便仅在视图布局后更改tintColor。这对我有用 例: AppaceaTextField.h
#import "MaterialTextFields.h"
@interface AppaceaTextField : MDCTextField
@end
AppaceaTextField.m
#import "AppaceaTextField.h"
@implementation AppaceaTextField
- (void) layoutSubviews{
[super layoutSubviews];
self.tintColor = [UIColor redColor];
}
@end
希望有帮助 我也遇到了同样的问题,并通过将MDCTextField子类化和覆盖layoutSubviews来解决了这个问题,以便仅在布局视图后更改tintColor。这对我有用 例: AppaceaTextField.h
#import "MaterialTextFields.h"
@interface AppaceaTextField : MDCTextField
@end
AppaceaTextField.m
#import "AppaceaTextField.h"
@implementation AppaceaTextField
- (void) layoutSubviews{
[super layoutSubviews];
self.tintColor = [UIColor redColor];
}
@end
希望有帮助 感谢您使用MDC iOS 光标颜色只是MDCTextField(.cursorColor)上的一个参数
它包含在38.1.0版中。感谢您使用MDC iOS 光标颜色只是MDCTextField(.cursorColor)上的一个参数
它包含在38.1.0版中。尝试了其他一切。除了这一点,没有什么能起作用:
let colorScheme=MDCSemanticColorScheme()
colorScheme.primaryColor=.systemBlue/尝试了其他一切。除了这一点,没有什么能起作用:
let colorScheme=MDCSemanticColorScheme()
colorScheme.primaryColor=.systemBlue//是的,但是当我这样做时,什么也不会发生。在MDCTextField
中必须有一些重写。是的,但是当我这样做时,什么也没有发生。MDCTextField
中必须有一些覆盖。谢谢,但光标颜色保持不变。MDCTextField
一定有什么特别之处mdcTextField.tintColor=.red
无效。谢谢,但光标颜色保持不变。MDCTextField
一定有什么特别之处mdcTextField.tintColor=.red
无效。