2014-10-02 82 views
7

在iOS 7中,更改uitextfield的「tint color」屬性將更改該文本字段的光標顏色。在iOS 8中,即使當我更改全局故事板色彩顏色時,也不會發生這種情況(objective-c,仍然適用於iOS 7)。我該如何解決?iOS 8文本字段色調顏色

回答

12

我只是試圖複製你的問題,但在iOS7.1和iOS8上,textfield的tintColor屬性完美地工作。

這行代碼更改了textField的光標顏色。試試這個,而不是改變故事板中的色調顏色

textField.tintColor = [UIColor colorWithRed:98.0/255.0f green:98.0/255.0f blue:98.0/255.0f alpha:1.0]; 

希望它有幫助!

+4

這應該是公認的。我仍然沒有得到它,爲什麼它不能通過故事板。 – appsunited 2014-11-27 11:18:18

+0

這是真的。不在故事板上工作 – 2016-04-08 02:38:35

8

嘗試以下操作:

[[self.textField setTintColor:[UIColor blueColor]]; 

[self.textField setTintAdjustmentMode:UIViewTintAdjustmentModeNormal]; 
+2

謝謝。沒有'self.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;'設置tintColor不起作用。 – 2015-07-30 07:46:38