質問編集履歴
2
fix1
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,4 +42,6 @@
|
|
42
42
|
|
43
43
|
foo.backgroundColor = .red を設定すると背景は赤くなるので tintColor だけ正常に動作していないと思われます。
|
44
44
|
|
45
|
+
環境はXcode9, Swift4, iOS11 です。
|
46
|
+
|
45
47
|
![イメージ説明](e20247c918107d3361d7d266471052aa.png)
|
1
fix
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,21 +1,45 @@
|
|
1
1
|
```swift
|
2
2
|
|
3
|
+
import UIKit
|
4
|
+
|
5
|
+
class ViewController: UIViewController, UISearchBarDelegate {
|
6
|
+
|
7
|
+
@IBOutlet weak var searchBar: UISearchBar!
|
8
|
+
|
9
|
+
override func viewDidLoad() {
|
10
|
+
|
11
|
+
super.viewDidLoad()
|
12
|
+
|
13
|
+
let textField = searchBar.value(forKey: "_searchField") as! UITextField
|
14
|
+
|
3
|
-
let foo = textField.value(forKey: "_clearButton") as! UIButton
|
15
|
+
let foo = textField.value(forKey: "_clearButton") as! UIButton
|
16
|
+
|
17
|
+
print(foo)
|
4
18
|
|
5
19
|
|
6
20
|
|
7
|
-
foo.setImage(f
|
21
|
+
foo.setImage(foo.imageView?.image?.withRenderingMode(.alwaysTemplate), for: .normal)
|
8
22
|
|
9
|
-
foo.setImage(f
|
23
|
+
foo.setImage(foo.imageView?.image?.withRenderingMode(.alwaysTemplate), for: .highlighted)
|
10
24
|
|
11
|
-
|
25
|
+
foo.backgroundColor = .red
|
12
26
|
|
13
27
|
foo.tintColor = .red
|
14
28
|
|
15
|
-
|
29
|
+
}
|
30
|
+
|
31
|
+
}
|
16
32
|
|
17
33
|
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
```
|
18
38
|
|
19
39
|
このコードを実行しても色が変わりません
|
20
40
|
|
21
41
|
textFieldの_clearButtonの色を変えるにはどのようにすればいいのでしょうか?
|
42
|
+
|
43
|
+
foo.backgroundColor = .red を設定すると背景は赤くなるので tintColor だけ正常に動作していないと思われます。
|
44
|
+
|
45
|
+
![イメージ説明](e20247c918107d3361d7d266471052aa.png)
|