回答編集履歴
3
修正
answer
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
attributeText.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.StyleSingle.rawValue, range: NSMakeRange(0, field.text?.characters.count ?? 0))
|
7
7
|
mylabel.attributedText = attributeText
|
8
8
|
}else {
|
9
|
-
attributeText.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.StyleNone.rawValue, range: NSMakeRange(0,
|
9
|
+
attributeText.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.StyleNone.rawValue, range: NSMakeRange(0, field.text?.characters.count ?? 0))
|
10
10
|
mylabel.attributedText = attributeText
|
11
11
|
}
|
12
12
|
}
|
2
修正
answer
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
attributeText.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.StyleSingle.rawValue, range: NSMakeRange(0, field.text?.characters.count ?? 0))
|
7
7
|
mylabel.attributedText = attributeText
|
8
8
|
}else {
|
9
|
-
attributeText.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.
|
9
|
+
attributeText.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.StyleNone.rawValue, range: NSMakeRange(0, mylabel.text?.characters.count ?? 0))
|
10
|
-
mylabel.attributedText = attributeText
|
10
|
+
mylabel.attributedText = attributeText
|
11
11
|
}
|
12
12
|
}
|
13
13
|
```
|
1
修正
answer
CHANGED
@@ -10,4 +10,10 @@
|
|
10
10
|
mylabel.attributedText = attributeText
|
11
11
|
}
|
12
12
|
}
|
13
|
+
```
|
14
|
+
|
15
|
+
あと文字を入力しないで、`Switch`を`ON`にすると落ちるので、`attributeText`を宣言のところで初期化しておくとよいと思います。
|
16
|
+
|
17
|
+
```swift
|
18
|
+
var attributeText = NSMutableAttributedString()
|
13
19
|
```
|