質問編集履歴

1

コードを具体的に修正しました

2016/11/07 22:16

投稿

goemon12
goemon12

スコア18

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,37 @@
4
4
 
5
5
  ```ここに言語を入力
6
6
 
7
+ override func draw(_ rect: CGRect) {
8
+
9
+ let context = UIGraphicsGetCurrentContext()
10
+
11
+ context!.setFillColor(UIColor.darkGray.cgColor)
12
+
13
+
14
+
15
+ //矩形
16
+
17
+ context!.fill(CGRect(x: 0, y: 0, width: 200, height: 300))
18
+
19
+
20
+
21
+ //文字属性
22
+
23
+ let att = [
24
+
25
+ NSFontAttributeName: UIFont(name: "Courier", size: 20.0)!,
26
+
27
+ NSForegroundColorAttributeName: UIColor.white]
28
+
29
+
30
+
31
+ //文字描画
32
+
7
- NSString(format: "hogehoge").draw(at: CGPoint(x: x1, y: y1), withAttributes: attr)
33
+ NSString(format: "%+4d mm", i).draw(at: CGPoint(x: 200, y: 300), withAttributes: att)
34
+
35
+ }
36
+
37
+
8
38
 
9
39
  ```
10
40