質問編集履歴

2

試したこと

2019/01/08 13:29

投稿

ShinnosukeU
ShinnosukeU

スコア15

test CHANGED
File without changes
test CHANGED
@@ -11,3 +11,27 @@
11
11
  #補足情報
12
12
 
13
13
  [Go Record Screen Recorder](https://itunes.apple.com/us/app/go-record-screen-recorder/id1345200849?mt=8)というアプリは実際にこの機能を実装しています。
14
+
15
+
16
+
17
+ #試したこと
18
+
19
+ ```swift
20
+
21
+ func captureScreen() -> UIImage? {
22
+
23
+ UIGraphicsBeginImageContext(view.frame.size)
24
+
25
+ view.layer.render(in: UIGraphicsGetCurrentContext()!)
26
+
27
+ let image = UIGraphicsGetImageFromCurrentImageContext()
28
+
29
+ UIGraphicsEndImageContext()
30
+
31
+ return image
32
+
33
+ }
34
+
35
+ ```
36
+
37
+ アプリがバックグラウンドにいるときに、このコードを実行すると、IOSのホームスクリーンではなく、アプリのUIのスクリーンショットが得られてしまいます。

1

2019/01/08 13:29

投稿

ShinnosukeU
ShinnosukeU

スコア15

test CHANGED
@@ -1 +1 @@
1
- swift でホームスクリーンのスクリーンショットを取るには
1
+ swift でIosのホームスクリーンのスクリーンショットを取るには
test CHANGED
File without changes