質問編集履歴
2
fix1
title
CHANGED
File without changes
|
body
CHANGED
@@ -20,4 +20,5 @@
|
|
20
20
|
このコードを実行しても色が変わりません
|
21
21
|
textFieldの_clearButtonの色を変えるにはどのようにすればいいのでしょうか?
|
22
22
|
foo.backgroundColor = .red を設定すると背景は赤くなるので tintColor だけ正常に動作していないと思われます。
|
23
|
+
環境はXcode9, Swift4, iOS11 です。
|
23
24
|

|
1
fix
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
```swift
|
2
|
+
import UIKit
|
3
|
+
class ViewController: UIViewController, UISearchBarDelegate {
|
4
|
+
@IBOutlet weak var searchBar: UISearchBar!
|
5
|
+
override func viewDidLoad() {
|
6
|
+
super.viewDidLoad()
|
7
|
+
let textField = searchBar.value(forKey: "_searchField") as! UITextField
|
2
|
-
let foo = textField.value(forKey: "_clearButton") as! UIButton
|
8
|
+
let foo = textField.value(forKey: "_clearButton") as! UIButton
|
9
|
+
print(foo)
|
3
10
|
|
4
|
-
foo.setImage(
|
11
|
+
foo.setImage(foo.imageView?.image?.withRenderingMode(.alwaysTemplate), for: .normal)
|
5
|
-
foo.setImage(
|
12
|
+
foo.setImage(foo.imageView?.image?.withRenderingMode(.alwaysTemplate), for: .highlighted)
|
6
|
-
|
13
|
+
foo.backgroundColor = .red
|
7
14
|
foo.tintColor = .red
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
|
8
19
|
```
|
9
|
-
|
10
20
|
このコードを実行しても色が変わりません
|
11
|
-
textFieldの_clearButtonの色を変えるにはどのようにすればいいのでしょうか?
|
21
|
+
textFieldの_clearButtonの色を変えるにはどのようにすればいいのでしょうか?
|
22
|
+
foo.backgroundColor = .red を設定すると背景は赤くなるので tintColor だけ正常に動作していないと思われます。
|
23
|
+

|