回答編集履歴
5
修正
answer
CHANGED
@@ -11,8 +11,12 @@
|
|
11
11
|
System Fontではガタつくことはありませんでした。
|
12
12
|
|
13
13
|
```swift
|
14
|
-
//
|
14
|
+
// ラベルのIBOutletにdidSetを追加
|
15
|
+
@IBOutlet private var countLabel: UILabel? {
|
16
|
+
didSet {
|
15
|
-
countLabel.font = countLabel.font.monospacedDigitFont
|
17
|
+
countLabel.font = countLabel.font.monospacedDigitFont
|
18
|
+
}
|
19
|
+
}
|
16
20
|
|
17
21
|
|
18
22
|
// 以下はextensionとしてViewControllerの外に置いてください。
|
4
修正
answer
CHANGED
@@ -1,4 +1,35 @@
|
|
1
1
|
ラベルのフォントを等幅フォントに変更してみてください。
|
2
2
|
|
3
3
|
例: Courier Regular
|
4
|
-

|
4
|
+

|
5
|
+
|
6
|
+
|
7
|
+
[How to get monospaced numbers in UILabel on iOS 9](http://stackoverflow.com/questions/30854690/how-to-get-monospaced-numbers-in-uilabel-on-ios-9)
|
8
|
+
|
9
|
+
上記の様な記事も見つけました、以下の様に組み込むとフォントを変更しなくても
|
10
|
+
見た目はやりたいことの様になるかもしれません。
|
11
|
+
System Fontではガタつくことはありませんでした。
|
12
|
+
|
13
|
+
```swift
|
14
|
+
// 現在のコードの中に以下を追加(viewDidAppearとかでOK)
|
15
|
+
countLabel.font = countLabel.font.monospacedDigitFont
|
16
|
+
|
17
|
+
|
18
|
+
// 以下はextensionとしてViewControllerの外に置いてください。
|
19
|
+
extension UIFont {
|
20
|
+
var monospacedDigitFont: UIFont {
|
21
|
+
let oldFontDescriptor = fontDescriptor()
|
22
|
+
let newFontDescriptor = oldFontDescriptor.monospacedDigitFontDescriptor
|
23
|
+
return UIFont(descriptor: newFontDescriptor, size: 0)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
private extension UIFontDescriptor {
|
28
|
+
var monospacedDigitFontDescriptor: UIFontDescriptor {
|
29
|
+
let fontDescriptorFeatureSettings = [[UIFontFeatureTypeIdentifierKey: kNumberSpacingType, UIFontFeatureSelectorIdentifierKey: kMonospacedNumbersSelector]]
|
30
|
+
let fontDescriptorAttributes = [UIFontDescriptorFeatureSettingsAttribute: fontDescriptorFeatureSettings]
|
31
|
+
let fontDescriptor = self.fontDescriptorByAddingAttributes(fontDescriptorAttributes)
|
32
|
+
return fontDescriptor
|
33
|
+
}
|
34
|
+
}
|
35
|
+
```
|
3
修正
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
ラベルのフォントを等幅フォントに変更してみてください。
|
2
2
|
|
3
|
-
例: Courier Regular
|
3
|
+
例: Courier Regular
|
4
|
-

|
2
修正
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
ラベルのフォントを等幅フォントに変更してみてください。
|
2
2
|
|
3
|
-
例:
|
3
|
+
例: Courier Regular等...
|
4
|
-

|
1
修正
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
等幅フォントに変更してみてください。
|
1
|
+
ラベルのフォントを等幅フォントに変更してみてください。
|
2
2
|
|
3
3
|
例: Helvetica Regular等...
|
4
4
|

|