回答編集履歴

5

修正

2016/05/04 15:24

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -24,9 +24,17 @@
24
24
 
25
25
  ```swift
26
26
 
27
- // 現在コードの中以下を追加(viewDidAppearとかでOK)
27
+ // ラベルIBOutletdidSetを追加
28
28
 
29
+ @IBOutlet private var countLabel: UILabel? {
30
+
31
+ didSet {
32
+
29
- countLabel.font = countLabel.font.monospacedDigitFont
33
+ countLabel.font = countLabel.font.monospacedDigitFont
34
+
35
+ }
36
+
37
+ }
30
38
 
31
39
 
32
40
 

4

修正

2016/05/04 15:24

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -5,3 +5,65 @@
5
5
  例: Courier Regular
6
6
 
7
7
  ![image](c1bc72f355772f95aa4bb75f8cf0f43c.png)
8
+
9
+
10
+
11
+
12
+
13
+ [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)
14
+
15
+
16
+
17
+ 上記の様な記事も見つけました、以下の様に組み込むとフォントを変更しなくても
18
+
19
+ 見た目はやりたいことの様になるかもしれません。
20
+
21
+ System Fontではガタつくことはありませんでした。
22
+
23
+
24
+
25
+ ```swift
26
+
27
+ // 現在のコードの中に以下を追加(viewDidAppearとかでOK)
28
+
29
+ countLabel.font = countLabel.font.monospacedDigitFont
30
+
31
+
32
+
33
+
34
+
35
+ // 以下はextensionとしてViewControllerの外に置いてください。
36
+
37
+ extension UIFont {
38
+
39
+ var monospacedDigitFont: UIFont {
40
+
41
+ let oldFontDescriptor = fontDescriptor()
42
+
43
+ let newFontDescriptor = oldFontDescriptor.monospacedDigitFontDescriptor
44
+
45
+ return UIFont(descriptor: newFontDescriptor, size: 0)
46
+
47
+ }
48
+
49
+ }
50
+
51
+
52
+
53
+ private extension UIFontDescriptor {
54
+
55
+ var monospacedDigitFontDescriptor: UIFontDescriptor {
56
+
57
+ let fontDescriptorFeatureSettings = [[UIFontFeatureTypeIdentifierKey: kNumberSpacingType, UIFontFeatureSelectorIdentifierKey: kMonospacedNumbersSelector]]
58
+
59
+ let fontDescriptorAttributes = [UIFontDescriptorFeatureSettingsAttribute: fontDescriptorFeatureSettings]
60
+
61
+ let fontDescriptor = self.fontDescriptorByAddingAttributes(fontDescriptorAttributes)
62
+
63
+ return fontDescriptor
64
+
65
+ }
66
+
67
+ }
68
+
69
+ ```

3

修正

2016/05/04 15:13

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
 
4
4
 
5
- 例: Courier Regular等...
5
+ 例: Courier Regular
6
6
 
7
- ![image説明](c1bc72f355772f95aa4bb75f8cf0f43c.png)
7
+ ![image](c1bc72f355772f95aa4bb75f8cf0f43c.png)

2

修正

2016/05/04 14:31

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
 
4
4
 
5
- 例: Helvetica Regular等...
5
+ 例: Courier Regular等...
6
6
 
7
- ![image](36b059c6b8ffae7ec1e5394250417018.png)
7
+ ![image説明](c1bc72f355772f95aa4bb75f8cf0f43c.png)

1

修正

2016/05/04 14:30

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -1,4 +1,4 @@
1
- 等幅フォントに変更してみてください。
1
+ ラベルのフォントを等幅フォントに変更してみてください。
2
2
 
3
3
 
4
4