回答編集履歴
1
訂正
answer
CHANGED
@@ -1,1 +1,30 @@
|
|
1
|
-
[ボタンタイプ](http://iphone-ipad-app-developer.com/2019/05/25/post-137/)を変更してみてください。
|
1
|
+
~~[ボタンタイプ](http://iphone-ipad-app-developer.com/2019/05/25/post-137/)を変更してみてください。~~
|
2
|
+
|
3
|
+
とりあえず、書き方が違うんだけど、
|
4
|
+
```swift
|
5
|
+
let good = UIImage(systemName: "heart.fill")
|
6
|
+
|
7
|
+
```
|
8
|
+
[用意されているプロパティを使って、](https://developer.apple.com/documentation/uikit/uicontrol/1618203-isselected)
|
9
|
+
|
10
|
+
```swift
|
11
|
+
|
12
|
+
//ボタンの初期設定時にイメージを設定しておいて
|
13
|
+
let good = UIImage(systemName: "heart")
|
14
|
+
let good_selected UIImage(systemName: "heart.fill")
|
15
|
+
btn.setImage(good, for: .normal)
|
16
|
+
btn.setImage(good_selected, for: .selected)
|
17
|
+
|
18
|
+
|
19
|
+
// タップされた際に
|
20
|
+
|
21
|
+
@IBAction func iineButtonTapped(_ sender: UIButton) {
|
22
|
+
|
23
|
+
sender.isSelected.toggle()
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
```
|
30
|
+
とかやるのがいいのかな。
|