回答編集履歴
3
コメントを受けて回答追加
answer
CHANGED
@@ -9,4 +9,17 @@
|
|
9
9
|
```
|
10
10
|
ここは `mail` ではなく `mails` だと思いますが、
|
11
11
|
そこを修正すれば、普通に文字の幅にあったメニューが表示されました。
|
12
|
-

|
12
|
+

|
13
|
+
|
14
|
+
---
|
15
|
+
(11/6 回答追加)
|
16
|
+
|
17
|
+
このDropDownライブラリは、ボタンの幅に合わせてメニューを表示するのがデフォルトの仕様になっているので、幅の広いボタンでメニューを表示したら、その幅に合わせた幅の広いメニューが表示されるのだと思います。DropDownライブラリの提供元のWebサイトで使い方を確認したところ、
|
18
|
+
|
19
|
+
```
|
20
|
+
// Will set a custom width instead of the anchor view width
|
21
|
+
dropDownLeft.width = 200
|
22
|
+
```
|
23
|
+
このようにwidthプロパティを設定すれば、指定した幅でメニューが表示されると説明されていました。
|
24
|
+
|
25
|
+
提供元のドキュメントをきちんと読んで使い方を調べることをお勧めします。
|
2
この質問の回答に修正しました。
answer
CHANGED
@@ -1,1 +1,12 @@
|
|
1
|
+
DropDownというのは、
|
2
|
+
[https://virtualsanpo.blogspot.com/2020/06/dropdownswift.html](https://virtualsanpo.blogspot.com/2020/06/dropdownswift.html)
|
3
|
+
で紹介されているDropDownライブラリでしょうか?
|
4
|
+
|
5
|
+
とりあえずこのライブラリをインストールして、質問に貼り付けられているコードをコピペし、Storyboardにボタンを貼り付けてoutlet接続とaction接続をしてみたところ
|
6
|
+
|
7
|
+
``` swift
|
8
|
+
menu.anchorView = mail
|
9
|
+
```
|
10
|
+
ここは `mail` ではなく `mails` だと思いますが、
|
1
|
-
す
|
11
|
+
そこを修正すれば、普通に文字の幅にあったメニューが表示されました。
|
12
|
+

|
1
回答場所誤り
answer
CHANGED
@@ -1,12 +1,1 @@
|
|
1
|
-
``` swift
|
2
|
-
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
3
|
-
```
|
4
|
-
|
5
|
-
上記のdelegateメソッドの第一引数は、 `_` をつけて外部引数名省略で宣言する必要があります。
|
6
|
-
```
|
7
|
-
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
8
|
-
```
|
9
|
-
|
10
|
-
それと、これは `UICollectionViewDelegateFlowLayout`プロトコルのdelegateメソッドなので、`UICollectionViewDelegateFlowLayout` に準拠することを指定する必要があります。
|
11
|
-
|
12
|
-
|
1
|
+
すみません。回答場所を間違えました。
|