質問編集履歴
1
文章の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
ラベルに間隔を開けようとしているのですが、うまくできません
|
2
2
|
|
3
|
-
|
3
|
+
普段は文字の間は間隔がありませんが
|
4
|
+
|
5
|
+
このmyLabelには文字と文字の間に間隔を入れたいわけです。
|
6
|
+
|
7
|
+
下の画像でいう赤い丸の部分みたいな感じです。
|
8
|
+
|
9
|
+
![イメージ説明](d01c439dd7c9d1499aa4677fa2149db2.png)
|
4
10
|
|
5
11
|
let myLabel: UILabel = UILabel(frame: CGRectMake(0,0,200,50))
|
6
12
|
|
7
|
-
|
8
|
-
|
9
13
|
myLabel.text = "Hello Swift!!"
|
10
|
-
|
11
|
-
|
12
14
|
|
13
15
|
view.addSubview(myLabel)
|
14
16
|
|
15
17
|
|
16
18
|
|
17
|
-
let attributedText = NSMutableAttributedString(string:my
|
19
|
+
let attributedText = NSMutableAttributedString(string:myLabel.text!)
|
18
20
|
|
19
21
|
let paragraphStyle = NSMutableParagraphStyle()
|
20
22
|
|
@@ -22,6 +24,16 @@
|
|
22
24
|
|
23
25
|
attributedText.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, attributedText.length))
|
24
26
|
|
27
|
+
myLabel.attributedText = attributeText
|
25
28
|
|
26
29
|
|
30
|
+
|
31
|
+
あ、⬆︎このコードは間違えました。
|
32
|
+
|
33
|
+
このコードは行数のやつですね笑
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
ラベルの間隔をあける方法ですよ(^^)
|
38
|
+
|
27
39
|
わかる方いたら教えてください!!
|