質問編集履歴

11

コードを必要なところだけに少なく変更

2016/09/10 12:45

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -24,6 +24,8 @@
24
24
 
25
25
  Iphoneシミュレーターを起動してarcを触ると self.tou.isScrollEnabled = isScrollEnableの所にエラーがでて落ちる (fatal error: unexpectedly found nil while unwrapping an Optional value)
26
26
 
27
+ ![エラー画面](e64d7d34869a7f45e52881e66d8b441e.png)
28
+
27
29
 
28
30
 
29
31
 
@@ -130,69 +132,69 @@
130
132
 
131
133
  class TestDraw: UIView {
132
134
 
133
-
135
+
134
136
 
135
137
  //パラメーターボタン
136
138
 
137
- var arc:UIBezierPath!
139
+ var parameterArc:UIBezierPath!
138
-
140
+
139
- var ino:UIBezierPath!
141
+ var parameterIno:UIBezierPath!
140
-
141
-
142
-
143
- var viewcon = ViewController()
142
+
143
+
144
+
145
+
144
146
 
145
147
  var radian:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
146
148
 
147
149
  var touchPoint:CGPoint!
148
150
 
149
-
150
-
151
-
152
-
151
+
152
+
153
+
154
+
153
- //ボタン内をタッチするとパラメーターが動く
155
+ //ボタン内をタッチするとパラメーターが動く
154
156
 
155
157
  override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
156
158
 
157
-
159
+
158
160
 
159
161
  if let touch = touches.first as UITouch? {
160
162
 
161
- let location = touch.location(in: self)
163
+ self.touchPoint = touch.location(in: self)
162
-
163
-
164
-
165
- touchPoint = location
164
+
166
-
167
-
168
-
165
+
166
+
167
+
168
+
169
+
170
+
169
- if arc.contains(touchPoint!) {
171
+ if parameterArc.contains(touchPoint!) {
172
+
170
-
173
+ var viewcon = ViewController()
171
-
172
-
174
+
173
- viewcon.isScrollEnable = false //ここでタッチした時にスクロールを止めたいです!
175
+ viewcon.isScrollEnable = false //ここでタッチした時にスクロールを止めたいです!
174
-
175
-
176
-
176
+
177
+
178
+
177
- //タッチした位置に合わせてパラメーターが変化
179
+ //タッチした位置に合わせてパラメーターが変化
178
-
180
+
179
- self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
181
+ self.radian = -atan2(100 - touchPoint.x, 350 - touchPoint.y) - CGFloat((M_PI)/2)
180
-
181
-
182
-
182
+
183
+
184
+
183
- if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
185
+ if self.radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
184
-
186
+
185
- radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
187
+ self.radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
186
-
188
+
187
- } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
189
+ } else if self.radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
188
-
190
+
189
- radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
191
+ self.radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
190
192
 
191
193
  }
192
194
 
193
-
194
-
195
+
196
+
195
- }
197
+ }
196
198
 
197
199
 
198
200
 
@@ -210,81 +212,77 @@
210
212
 
211
213
  override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
212
214
 
213
-
215
+
214
216
 
215
217
 
216
218
 
217
219
  if let touch = touches.first as UITouch? {
218
220
 
219
- let location = touch.location(in: self)
221
+ self.touchPoint = touch.location(in: self)
220
-
221
-
222
-
222
+
223
+
224
+
223
- if arc.contains(touchPoint!) {
225
+ if parameterArc.contains(touchPoint!) {
224
-
225
-
226
-
226
+
227
+
228
+
227
- //パラメータの変化
229
+ //パラメータの変化
228
-
230
+
229
- self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
231
+ self.radian = -atan2(100 - touchPoint.x, 350 - touchPoint.y) - CGFloat((M_PI)/2)
230
-
231
-
232
-
232
+
233
+
234
+
233
- if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
235
+ if self.radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
234
-
236
+
235
- radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
237
+ self.radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
236
-
238
+
237
- } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
239
+ } else if self.radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
238
-
240
+
239
- radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
241
+ self.radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
240
242
 
241
243
  }
242
244
 
243
- }
245
+ }
244
-
245
-
246
+
247
+
246
248
 
247
249
  self.setNeedsDisplay()
248
250
 
249
- }
251
+ }
250
-
251
-
252
-
252
+
253
+
254
+
253
- }
255
+ }
254
-
255
-
256
-
257
-
258
-
256
+
257
+
258
+
259
+
260
+
259
- //パラメーターの設定、設置
261
+ //パラメーターの設定、設置
260
262
 
261
263
  override func draw(_ rect: CGRect){
262
264
 
263
265
 
264
266
 
265
- self.arc = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40,
266
-
267
- startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
267
+ self.parameterIno = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40,startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
268
-
269
-
270
-
268
+
269
+
270
+
271
- let aColor = UIColor(red: 0, green: 0.5, blue: 1, alpha: 0.8)
271
+ let arcColor = UIColor(red: 0, green: 0.5, blue: 1, alpha: 0.8)
272
-
272
+
273
- aColor.setStroke()
273
+ arcColor.setStroke()
274
-
274
+
275
- arc.lineWidth = 4
275
+ parameterArc.lineWidth = 4
276
-
276
+
277
- arc.lineCapStyle = CGLineCap.round
277
+ parameterArc.lineCapStyle = CGLineCap.round
278
-
278
+
279
- arc.stroke()
279
+ parameterIno.stroke()
280
-
281
-
282
-
283
-
284
-
285
- self.ino = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40,
280
+
286
-
281
+
282
+
283
+
284
+
287
- startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian) , clockwise: true)
285
+ self.parameterIno = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40,startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian) , clockwise: true)
288
286
 
289
287
 
290
288
 
@@ -292,17 +290,17 @@
292
290
 
293
291
  inoColor.setStroke()
294
292
 
295
- ino.lineWidth = 4.4
293
+ parameterIno.lineWidth = 4.4
296
-
294
+
297
- ino.lineCapStyle = CGLineCap.round
295
+ parameterIno.lineCapStyle = CGLineCap.round
298
-
296
+
299
- ino.stroke()
297
+ parameterIno.stroke()
300
-
301
-
302
-
298
+
299
+
300
+
303
- }
301
+ }
304
-
305
-
302
+
303
+
306
304
 
307
305
  }
308
306
 

10

コード編集

2016/09/10 12:44

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -276,8 +276,6 @@
276
276
 
277
277
  arc.lineCapStyle = CGLineCap.round
278
278
 
279
-
280
-
281
279
  arc.stroke()
282
280
 
283
281
 

9

画像サイズの変更

2016/09/10 12:00

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  ###アプリ画面
14
14
 
15
- ![アプリ画面](aaa53e4b5da1ce6317ef18fff6bb9a71.png)
15
+ ![アプリイメージ](7c4d86488c6159333bee9fa84142005c.png)
16
16
 
17
17
 
18
18
 

8

コードに説明コメントを追加

2016/09/10 11:57

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
  通常時はスクロールをONにして TestDrawクラス内にあるarcとinoパラメーターをタッチした時にスクロールを止めたい
10
10
 
11
+
12
+
13
+ ###アプリ画面
14
+
11
15
  ![アプリ画面](aaa53e4b5da1ce6317ef18fff6bb9a71.png)
12
16
 
13
17
 
@@ -50,11 +54,9 @@
50
54
 
51
55
  var isScrollEnable = true {
52
56
 
53
-
54
-
55
- didSet {
57
+ didSet {
56
-
58
+
57
- viewDidLoad()
59
+ viewDidLoad()
58
60
 
59
61
  }
60
62
 
@@ -72,7 +74,7 @@
72
74
 
73
75
  self.tou.isScrollEnabled = isScrollEnable /*ここを変更したいですがエラーが出ます(fatal error: unexpectedly found nil while unwrapping an Optional value)*/
74
76
 
75
-
77
+ //スクロール画面の設定
76
78
 
77
79
  self.tou.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
78
80
 
@@ -82,11 +84,9 @@
82
84
 
83
85
 
84
86
 
85
-
86
-
87
- let screenWidth = self.view.bounds.width
87
+ //パラメーターボタンの設置
88
-
88
+
89
- let testDraw = TestDraw(frame: CGRect(x: 0, y: 0, width: screenWidth, height: 900 ))
89
+ let testDraw = TestDraw(frame: CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 900 ))
90
90
 
91
91
  testDraw.backgroundColor = UIColor.clear()
92
92
 
@@ -132,20 +132,20 @@
132
132
 
133
133
 
134
134
 
135
-
135
+ //パラメーターボタン
136
+
137
+ var arc:UIBezierPath!
138
+
139
+ var ino:UIBezierPath!
140
+
141
+
142
+
143
+ var viewcon = ViewController()
144
+
145
+ var radian:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
136
146
 
137
147
  var touchPoint:CGPoint!
138
148
 
139
- var arc:UIBezierPath!
140
-
141
- var ino:UIBezierPath!
142
-
143
- var viewcon = ViewController()
144
-
145
- var radian:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
146
-
147
-
148
-
149
149
 
150
150
 
151
151
 
@@ -174,7 +174,7 @@
174
174
 
175
175
 
176
176
 
177
-
177
+ //タッチした位置に合わせてパラメーターが変化
178
178
 
179
179
  self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
180
180
 
@@ -206,7 +206,7 @@
206
206
 
207
207
 
208
208
 
209
-
209
+ //タッチ後動かしてもパラメーターを変化させる
210
210
 
211
211
  override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
212
212
 
@@ -224,6 +224,8 @@
224
224
 
225
225
 
226
226
 
227
+ //パラメータの変化
228
+
227
229
  self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
228
230
 
229
231
 
@@ -254,7 +256,7 @@
254
256
 
255
257
 
256
258
 
257
-
259
+ //パラメーターの設定、設置
258
260
 
259
261
  override func draw(_ rect: CGRect){
260
262
 

7

本文の改善

2016/09/10 11:53

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -2,15 +2,29 @@
2
2
 
3
3
 
4
4
 
5
+ ###前提・実現したいこと
6
+
7
+
8
+
5
- ラスからViewControllerのoverride func viewDidLoad() の中変更する方法がわからなくて質問させていただきました
9
+ 通常時はスロールをONにして TestDrawクラスにあるarcとinoパラメータータッチした時にスクロールを止めたい
10
+
6
-
11
+ ![アプリ画面](aaa53e4b5da1ce6317ef18fff6bb9a71.png)
12
+
13
+
14
+
15
+
16
+
7
-
17
+ ###発生している問題・エラーメッセージ
8
-
18
+
19
+
20
+
9
- 具体的には、遷移せずに同じ画面内に[UIViewでアニメーョンするパラメータを作っおり(これが他クラスです)]それタッチするとスクロールが止まるという感じです。override func viewDidLoad()内のself.tou.isScrollEnabled = true falseに変更したいです
21
+ Iphoneシミュレータ起動しarcると self.tou.isScrollEnabled = isScrollEnableの所にエラーがでて落ちる (fatal error: unexpectedly found nil while unwrapping an Optional value)
10
-
11
-
12
-
22
+
23
+
24
+
25
+
26
+
13
- ご回答いただけるとありがたいです
27
+ viewDidLoad内の情報を他クラスから変更する方法はないでしょうか?ご回答いただけるとありがたいです
14
28
 
15
29
 
16
30
 
@@ -34,7 +48,17 @@
34
48
 
35
49
  @IBOutlet weak var tou: UIScrollView!
36
50
 
37
-
51
+ var isScrollEnable = true {
52
+
53
+
54
+
55
+ didSet {
56
+
57
+ viewDidLoad()
58
+
59
+ }
60
+
61
+ }
38
62
 
39
63
 
40
64
 
@@ -46,7 +70,7 @@
46
70
 
47
71
 
48
72
 
49
- self.tou.isScrollEnabled = false //ここを変更したいです
73
+ self.tou.isScrollEnabled = isScrollEnable /*ここを変更したいですがエラーが出ます(fatal error: unexpectedly found nil while unwrapping an Optional value)*/
50
74
 
51
75
 
52
76
 
@@ -64,8 +88,6 @@
64
88
 
65
89
  let testDraw = TestDraw(frame: CGRect(x: 0, y: 0, width: screenWidth, height: 900 ))
66
90
 
67
-
68
-
69
91
  testDraw.backgroundColor = UIColor.clear()
70
92
 
71
93
 
@@ -110,23 +132,25 @@
110
132
 
111
133
 
112
134
 
135
+
136
+
137
+ var touchPoint:CGPoint!
138
+
139
+ var arc:UIBezierPath!
140
+
141
+ var ino:UIBezierPath!
142
+
143
+ var viewcon = ViewController()
144
+
113
145
  var radian:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
114
146
 
147
+
148
+
115
149
 
116
150
 
117
-
118
-
151
+
152
+
119
- var touchPoint:CGPoint!
153
+ //ボタン内をタッチするとパラメーターが動く
120
-
121
- var arc:UIBezierPath!
122
-
123
- var ino:UIBezierPath!
124
-
125
-
126
-
127
-
128
-
129
-
130
154
 
131
155
  override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
132
156
 
@@ -144,7 +168,9 @@
144
168
 
145
169
  if arc.contains(touchPoint!) {
146
170
 
171
+
172
+
147
- //ここでタッチした時にスクロールを止めたいです!
173
+ viewcon.isScrollEnable = false //ここでタッチした時にスクロールを止めたいです!
148
174
 
149
175
 
150
176
 
@@ -192,9 +218,7 @@
192
218
 
193
219
  let location = touch.location(in: self)
194
220
 
195
-
196
-
197
-
221
+
198
222
 
199
223
  if arc.contains(touchPoint!) {
200
224
 
@@ -224,8 +248,6 @@
224
248
 
225
249
 
226
250
 
227
-
228
-
229
251
  }
230
252
 
231
253
 
@@ -238,7 +260,9 @@
238
260
 
239
261
 
240
262
 
263
+ self.arc = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40,
264
+
241
- self.arc = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
265
+ startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
242
266
 
243
267
 
244
268
 
@@ -254,9 +278,13 @@
254
278
 
255
279
  arc.stroke()
256
280
 
281
+
282
+
283
+
284
+
257
-
285
+ self.ino = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40,
258
-
286
+
259
- self.ino = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian) , clockwise: true)
287
+ startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian) , clockwise: true)
260
288
 
261
289
 
262
290
 
@@ -282,6 +310,6 @@
282
310
 
283
311
  ##補足情報(言語/FW/ツール等のバージョンなど)
284
312
 
285
- xcode8 beta6
313
+ xcode8 beta
286
314
 
287
315
  swift3.0

6

コードをシンプルに見やすくしました

2016/09/10 11:33

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -112,7 +112,7 @@
112
112
 
113
113
  var radian:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
114
114
 
115
- var radian2:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
115
+
116
116
 
117
117
 
118
118
 
@@ -120,7 +120,9 @@
120
120
 
121
121
  var arc:UIBezierPath!
122
122
 
123
- var arc2:UIBezierPath!
123
+ var ino:UIBezierPath!
124
+
125
+
124
126
 
125
127
 
126
128
 
@@ -164,100 +166,60 @@
164
166
 
165
167
 
166
168
 
169
+ }
170
+
171
+
172
+
173
+ self.setNeedsDisplay()
174
+
175
+
176
+
177
+ }
178
+
179
+ }
180
+
181
+
182
+
183
+
184
+
185
+ override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
186
+
187
+
188
+
189
+
190
+
191
+ if let touch = touches.first as UITouch? {
192
+
193
+ let location = touch.location(in: self)
194
+
195
+
196
+
197
+
198
+
167
- } else if arc2.contains(touchPoint!) {
199
+ if arc.contains(touchPoint!) {
168
-
169
-
170
-
171
-
172
-
200
+
201
+
202
+
173
- self.radian2 = -atan2(260 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
203
+ self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
174
-
175
-
176
-
204
+
205
+
206
+
177
- if radian2 >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
207
+ if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
178
-
208
+
179
- radian2 = CGFloat((M_PI)*4/5 - (M_PI)/2)
209
+ radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
180
-
210
+
181
- } else if radian2 <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
211
+ } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
182
-
212
+
183
- radian2 = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
213
+ radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
184
214
 
185
215
  }
186
216
 
187
- }
217
+ }
188
-
189
-
218
+
219
+
190
220
 
191
221
  self.setNeedsDisplay()
192
222
 
193
-
194
-
195
- }
196
-
197
- }
198
-
199
-
200
-
201
-
202
-
203
- override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
204
-
205
-
206
-
207
-
208
-
209
- if let touch = touches.first as UITouch? {
210
-
211
- let location = touch.location(in: self)
212
-
213
-
214
-
215
-
216
-
217
- if arc.contains(touchPoint!) {
218
-
219
-
220
-
221
- self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
222
-
223
-
224
-
225
- if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
226
-
227
- radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
228
-
229
- } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
230
-
231
- radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
232
-
233
- }
234
-
235
- } else if arc2.contains(touchPoint!) {
236
-
237
-
238
-
239
-
240
-
241
- self.radian2 = -atan2(260 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
242
-
243
-
244
-
245
- if radian2 >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
246
-
247
- radian2 = CGFloat((M_PI)*4/5 - (M_PI)/2)
248
-
249
- } else if radian2 <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
250
-
251
- radian2 = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
252
-
253
- }
254
-
255
- }
256
-
257
-
258
-
259
- self.setNeedsDisplay()
260
-
261
223
  }
262
224
 
263
225
 
@@ -276,7 +238,7 @@
276
238
 
277
239
 
278
240
 
279
- arc = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
241
+ self.arc = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
280
242
 
281
243
 
282
244
 
@@ -294,7 +256,7 @@
294
256
 
295
257
 
296
258
 
297
- let ino = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian) , clockwise: true)
259
+ self.ino = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian) , clockwise: true)
298
260
 
299
261
 
300
262
 
@@ -310,50 +272,6 @@
310
272
 
311
273
 
312
274
 
313
-
314
-
315
- arc2 = UIBezierPath(arcCenter: CGPoint(x:245, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
316
-
317
-
318
-
319
- let aColor2 = UIColor(red: 0, green: 0.5, blue: 1, alpha: 0.8)
320
-
321
- aColor2.setStroke()
322
-
323
- arc2.lineWidth = 4.4
324
-
325
- arc2.lineCapStyle = CGLineCap.round
326
-
327
-
328
-
329
- arc2.stroke()
330
-
331
-
332
-
333
- let ino2 = UIBezierPath(arcCenter: CGPoint(x:245, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian2) , clockwise: true)
334
-
335
-
336
-
337
- let inoColor2 = UIColor(red: 0, green: 0.1, blue: 0.4, alpha: 1)
338
-
339
- inoColor2.setStroke()
340
-
341
- ino2.lineWidth = 4.4
342
-
343
- ino2.lineCapStyle = CGLineCap.round
344
-
345
- ino2.stroke()
346
-
347
-
348
-
349
-
350
-
351
-
352
-
353
-
354
-
355
-
356
-
357
275
  }
358
276
 
359
277
 

5

テストの終了

2016/09/10 08:34

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -12,360 +12,356 @@
12
12
 
13
13
  ご回答いただけるとありがたいです
14
14
 
15
+
16
+
17
+
18
+
19
+ ###該当のソースコード
20
+
15
21
  ```swift
16
22
 
23
+ import UIKit
24
+
25
+ import CoreGraphics
26
+
27
+
28
+
29
+ class ViewController: UIViewController {
30
+
31
+
32
+
33
+
34
+
35
+ @IBOutlet weak var tou: UIScrollView!
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ override func viewDidLoad() {
44
+
45
+ super.viewDidLoad()
46
+
47
+
48
+
49
+ self.tou.isScrollEnabled = false //ここを変更したいです
50
+
51
+
52
+
53
+ self.tou.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
54
+
55
+ self.tou.contentSize = CGSize(width: self.view.frame.size.width, height: 900)
56
+
57
+ self.tou.showsVerticalScrollIndicator = false
58
+
59
+
60
+
61
+
62
+
63
+ let screenWidth = self.view.bounds.width
64
+
65
+ let testDraw = TestDraw(frame: CGRect(x: 0, y: 0, width: screenWidth, height: 900 ))
66
+
67
+
68
+
69
+ testDraw.backgroundColor = UIColor.clear()
70
+
71
+
72
+
73
+ self.tou.addSubview(testDraw)
74
+
75
+ self.view.addSubview(self.tou)
76
+
77
+
78
+
17
- コード
79
+ }
80
+
81
+
82
+
83
+ override func didReceiveMemoryWarning() {
84
+
85
+ super.didReceiveMemoryWarning()
86
+
87
+ // Dispose of any resources that can be recreated.
88
+
89
+ }
90
+
91
+
92
+
93
+
94
+
95
+ }
96
+
97
+
98
+
99
+
18
100
 
19
101
  ```
20
102
 
21
-
22
-
23
- ###該当のソースコード
24
-
25
103
  ```swift
26
104
 
27
105
  import UIKit
28
106
 
29
- import CoreGraphics
107
+
30
-
31
-
32
-
108
+
33
- class ViewController: UIViewController {
109
+ class TestDraw: UIView {
110
+
111
+
112
+
34
-
113
+ var radian:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
114
+
35
-
115
+ var radian2:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
36
-
37
-
38
-
116
+
117
+
118
+
39
- @IBOutlet weak var tou: UIScrollView!
119
+ var touchPoint:CGPoint!
120
+
121
+ var arc:UIBezierPath!
122
+
123
+ var arc2:UIBezierPath!
40
124
 
41
125
 
42
126
 
43
127
 
44
128
 
45
-
129
+ override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
130
+
131
+
132
+
46
-
133
+ if let touch = touches.first as UITouch? {
134
+
135
+ let location = touch.location(in: self)
136
+
137
+
138
+
139
+ touchPoint = location
140
+
141
+
142
+
47
- override func viewDidLoad() {
143
+ if arc.contains(touchPoint!) {
144
+
48
-
145
+ //ここでタッチした時にスクロールを止めたいです!
146
+
147
+
148
+
149
+
150
+
151
+ self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
152
+
153
+
154
+
155
+ if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
156
+
157
+ radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
158
+
159
+ } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
160
+
161
+ radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
162
+
163
+ }
164
+
165
+
166
+
167
+ } else if arc2.contains(touchPoint!) {
168
+
169
+
170
+
171
+
172
+
173
+ self.radian2 = -atan2(260 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
174
+
175
+
176
+
177
+ if radian2 >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
178
+
179
+ radian2 = CGFloat((M_PI)*4/5 - (M_PI)/2)
180
+
181
+ } else if radian2 <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
182
+
183
+ radian2 = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
184
+
185
+ }
186
+
187
+ }
188
+
189
+
190
+
49
- super.viewDidLoad()
191
+ self.setNeedsDisplay()
50
-
51
-
52
-
192
+
193
+
194
+
53
- self.tou.isScrollEnabled = false //ここを変更したいです
195
+ }
54
-
55
-
56
-
196
+
57
- self.tou.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
197
+ }
58
-
198
+
199
+
200
+
201
+
202
+
59
- self.tou.contentSize = CGSize(width: self.view.frame.size.width, height: 900)
203
+ override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
60
-
204
+
205
+
206
+
207
+
208
+
61
- self.tou.showsVerticalScrollIndicator = false
209
+ if let touch = touches.first as UITouch? {
62
-
63
-
64
-
65
-
66
-
210
+
67
- let screenWidth = self.view.bounds.width
211
+ let location = touch.location(in: self)
68
-
69
- let testDraw = TestDraw(frame: CGRect(x: 0, y: 0, width: screenWidth, height: 900 ))
70
212
 
71
213
 
72
214
 
73
- testDraw.backgroundColor = UIColor.clear()
74
-
75
-
76
-
77
- self.tou.addSubview(testDraw)
78
-
79
- self.view.addSubview(self.tou)
80
-
81
-
82
-
83
- }
84
-
85
-
86
-
87
- override func didReceiveMemoryWarning() {
88
-
89
- super.didReceiveMemoryWarning()
90
-
91
- // Dispose of any resources that can be recreated.
92
-
93
- }
94
-
95
-
96
-
97
-
215
+
216
+
217
+ if arc.contains(touchPoint!) {
218
+
219
+
220
+
221
+ self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
222
+
223
+
224
+
225
+ if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
226
+
227
+ radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
228
+
229
+ } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
230
+
231
+ radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
232
+
233
+ }
234
+
235
+ } else if arc2.contains(touchPoint!) {
236
+
237
+
238
+
239
+
240
+
241
+ self.radian2 = -atan2(260 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
242
+
243
+
244
+
245
+ if radian2 >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
246
+
247
+ radian2 = CGFloat((M_PI)*4/5 - (M_PI)/2)
248
+
249
+ } else if radian2 <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
250
+
251
+ radian2 = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
252
+
253
+ }
254
+
255
+ }
256
+
257
+
258
+
259
+ self.setNeedsDisplay()
260
+
261
+ }
262
+
263
+
264
+
265
+
266
+
267
+ }
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+ override func draw(_ rect: CGRect){
276
+
277
+
278
+
279
+ arc = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
280
+
281
+
282
+
283
+ let aColor = UIColor(red: 0, green: 0.5, blue: 1, alpha: 0.8)
284
+
285
+ aColor.setStroke()
286
+
287
+ arc.lineWidth = 4
288
+
289
+ arc.lineCapStyle = CGLineCap.round
290
+
291
+
292
+
293
+ arc.stroke()
294
+
295
+
296
+
297
+ let ino = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian) , clockwise: true)
298
+
299
+
300
+
301
+ let inoColor = UIColor(red: 0, green: 0.2, blue: 0.5, alpha: 1)
302
+
303
+ inoColor.setStroke()
304
+
305
+ ino.lineWidth = 4.4
306
+
307
+ ino.lineCapStyle = CGLineCap.round
308
+
309
+ ino.stroke()
310
+
311
+
312
+
313
+
314
+
315
+ arc2 = UIBezierPath(arcCenter: CGPoint(x:245, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
316
+
317
+
318
+
319
+ let aColor2 = UIColor(red: 0, green: 0.5, blue: 1, alpha: 0.8)
320
+
321
+ aColor2.setStroke()
322
+
323
+ arc2.lineWidth = 4.4
324
+
325
+ arc2.lineCapStyle = CGLineCap.round
326
+
327
+
328
+
329
+ arc2.stroke()
330
+
331
+
332
+
333
+ let ino2 = UIBezierPath(arcCenter: CGPoint(x:245, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian2) , clockwise: true)
334
+
335
+
336
+
337
+ let inoColor2 = UIColor(red: 0, green: 0.1, blue: 0.4, alpha: 1)
338
+
339
+ inoColor2.setStroke()
340
+
341
+ ino2.lineWidth = 4.4
342
+
343
+ ino2.lineCapStyle = CGLineCap.round
344
+
345
+ ino2.stroke()
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+ }
358
+
359
+
98
360
 
99
361
  }
100
362
 
101
-
102
-
103
-
104
-
105
363
  ```
106
364
 
107
- ```swift
108
-
109
- import UIKit
110
-
111
-
112
-
113
- class TestDraw: UIView {
114
-
115
-
116
-
117
- var radian:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
118
-
119
- var radian2:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
120
-
121
-
122
-
123
- var touchPoint:CGPoint!
124
-
125
- var arc:UIBezierPath!
126
-
127
- var arc2:UIBezierPath!
128
-
129
-
130
-
131
-
132
-
133
- override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
134
-
135
-
136
-
137
- if let touch = touches.first as UITouch? {
138
-
139
- let location = touch.location(in: self)
140
-
141
-
142
-
143
- touchPoint = location
144
-
145
-
146
-
147
- if arc.contains(touchPoint!) {
148
-
149
- //ここでタッチした時にスクロールを止めたいです!
150
-
151
-
152
-
153
-
154
-
155
- self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
156
-
157
-
158
-
159
- if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
160
-
161
- radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
162
-
163
- } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
164
-
165
- radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
166
-
167
- }
168
-
169
-
170
-
171
- } else if arc2.contains(touchPoint!) {
172
-
173
-
174
-
175
-
176
-
177
- self.radian2 = -atan2(260 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
178
-
179
-
180
-
181
- if radian2 >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
182
-
183
- radian2 = CGFloat((M_PI)*4/5 - (M_PI)/2)
184
-
185
- } else if radian2 <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
186
-
187
- radian2 = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
188
-
189
- }
190
-
191
- }
192
-
193
-
194
-
195
- self.setNeedsDisplay()
196
-
197
-
198
-
199
- }
200
-
201
- }
202
-
203
-
204
-
205
-
206
-
207
- override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
208
-
209
-
210
-
211
-
212
-
213
- if let touch = touches.first as UITouch? {
214
-
215
- let location = touch.location(in: self)
216
-
217
-
218
-
219
-
220
-
221
- if arc.contains(touchPoint!) {
222
-
223
-
224
-
225
- self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
226
-
227
-
228
-
229
- if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
230
-
231
- radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
232
-
233
- } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
234
-
235
- radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
236
-
237
- }
238
-
239
- } else if arc2.contains(touchPoint!) {
240
-
241
-
242
-
243
-
244
-
245
- self.radian2 = -atan2(260 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
246
-
247
-
248
-
249
- if radian2 >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
250
-
251
- radian2 = CGFloat((M_PI)*4/5 - (M_PI)/2)
252
-
253
- } else if radian2 <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
254
-
255
- radian2 = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
256
-
257
- }
258
-
259
- }
260
-
261
-
262
-
263
- self.setNeedsDisplay()
264
-
265
- }
266
-
267
-
268
-
269
-
270
-
271
- }
272
-
273
-
274
-
275
-
276
-
277
-
278
-
279
- override func draw(_ rect: CGRect){
280
-
281
-
282
-
283
- arc = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
284
-
285
-
286
-
287
- let aColor = UIColor(red: 0, green: 0.5, blue: 1, alpha: 0.8)
288
-
289
- aColor.setStroke()
290
-
291
- arc.lineWidth = 4
292
-
293
- arc.lineCapStyle = CGLineCap.round
294
-
295
-
296
-
297
- arc.stroke()
298
-
299
-
300
-
301
- let ino = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian) , clockwise: true)
302
-
303
-
304
-
305
- let inoColor = UIColor(red: 0, green: 0.2, blue: 0.5, alpha: 1)
306
-
307
- inoColor.setStroke()
308
-
309
- ino.lineWidth = 4.4
310
-
311
- ino.lineCapStyle = CGLineCap.round
312
-
313
- ino.stroke()
314
-
315
-
316
-
317
-
318
-
319
- arc2 = UIBezierPath(arcCenter: CGPoint(x:245, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
320
-
321
-
322
-
323
- let aColor2 = UIColor(red: 0, green: 0.5, blue: 1, alpha: 0.8)
324
-
325
- aColor2.setStroke()
326
-
327
- arc2.lineWidth = 4.4
328
-
329
- arc2.lineCapStyle = CGLineCap.round
330
-
331
-
332
-
333
- arc2.stroke()
334
-
335
-
336
-
337
- let ino2 = UIBezierPath(arcCenter: CGPoint(x:245, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian2) , clockwise: true)
338
-
339
-
340
-
341
- let inoColor2 = UIColor(red: 0, green: 0.1, blue: 0.4, alpha: 1)
342
-
343
- inoColor2.setStroke()
344
-
345
- ino2.lineWidth = 4.4
346
-
347
- ino2.lineCapStyle = CGLineCap.round
348
-
349
- ino2.stroke()
350
-
351
-
352
-
353
-
354
-
355
-
356
-
357
-
358
-
359
-
360
-
361
- }
362
-
363
-
364
-
365
- }
366
-
367
- ```
368
-
369
365
  ##補足情報(言語/FW/ツール等のバージョンなど)
370
366
 
371
367
  xcode8 beta6

4

codeの書き方のテスト

2016/09/09 10:22

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,11 @@
12
12
 
13
13
  ご回答いただけるとありがたいです
14
14
 
15
-
15
+ ```swift
16
+
17
+ コード
18
+
19
+ ```
16
20
 
17
21
 
18
22
 

3

わかりやすくするために関連コードの追加

2016/09/09 10:21

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -100,6 +100,268 @@
100
100
 
101
101
  ```
102
102
 
103
+ ```swift
104
+
105
+ import UIKit
106
+
107
+
108
+
109
+ class TestDraw: UIView {
110
+
111
+
112
+
113
+ var radian:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
114
+
115
+ var radian2:CGFloat = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
116
+
117
+
118
+
119
+ var touchPoint:CGPoint!
120
+
121
+ var arc:UIBezierPath!
122
+
123
+ var arc2:UIBezierPath!
124
+
125
+
126
+
127
+
128
+
129
+ override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
130
+
131
+
132
+
133
+ if let touch = touches.first as UITouch? {
134
+
135
+ let location = touch.location(in: self)
136
+
137
+
138
+
139
+ touchPoint = location
140
+
141
+
142
+
143
+ if arc.contains(touchPoint!) {
144
+
145
+ //ここでタッチした時にスクロールを止めたいです!
146
+
147
+
148
+
149
+
150
+
151
+ self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
152
+
153
+
154
+
155
+ if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
156
+
157
+ radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
158
+
159
+ } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
160
+
161
+ radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
162
+
163
+ }
164
+
165
+
166
+
167
+ } else if arc2.contains(touchPoint!) {
168
+
169
+
170
+
171
+
172
+
173
+ self.radian2 = -atan2(260 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
174
+
175
+
176
+
177
+ if radian2 >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
178
+
179
+ radian2 = CGFloat((M_PI)*4/5 - (M_PI)/2)
180
+
181
+ } else if radian2 <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
182
+
183
+ radian2 = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
184
+
185
+ }
186
+
187
+ }
188
+
189
+
190
+
191
+ self.setNeedsDisplay()
192
+
193
+
194
+
195
+ }
196
+
197
+ }
198
+
199
+
200
+
201
+
202
+
203
+ override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
204
+
205
+
206
+
207
+
208
+
209
+ if let touch = touches.first as UITouch? {
210
+
211
+ let location = touch.location(in: self)
212
+
213
+
214
+
215
+
216
+
217
+ if arc.contains(touchPoint!) {
218
+
219
+
220
+
221
+ self.radian = -atan2(100 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
222
+
223
+
224
+
225
+ if radian >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
226
+
227
+ radian = CGFloat((M_PI)*4/5 - (M_PI)/2)
228
+
229
+ } else if radian <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
230
+
231
+ radian = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
232
+
233
+ }
234
+
235
+ } else if arc2.contains(touchPoint!) {
236
+
237
+
238
+
239
+
240
+
241
+ self.radian2 = -atan2(260 - location.x, 350 - location.y) - CGFloat((M_PI)/2)
242
+
243
+
244
+
245
+ if radian2 >= CGFloat((M_PI)*4/5 - (M_PI)/2) {
246
+
247
+ radian2 = CGFloat((M_PI)*4/5 - (M_PI)/2)
248
+
249
+ } else if radian2 <= -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2) {
250
+
251
+ radian2 = -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2)
252
+
253
+ }
254
+
255
+ }
256
+
257
+
258
+
259
+ self.setNeedsDisplay()
260
+
261
+ }
262
+
263
+
264
+
265
+
266
+
267
+ }
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+ override func draw(_ rect: CGRect){
276
+
277
+
278
+
279
+ arc = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
280
+
281
+
282
+
283
+ let aColor = UIColor(red: 0, green: 0.5, blue: 1, alpha: 0.8)
284
+
285
+ aColor.setStroke()
286
+
287
+ arc.lineWidth = 4
288
+
289
+ arc.lineCapStyle = CGLineCap.round
290
+
291
+
292
+
293
+ arc.stroke()
294
+
295
+
296
+
297
+ let ino = UIBezierPath(arcCenter: CGPoint(x:120, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian) , clockwise: true)
298
+
299
+
300
+
301
+ let inoColor = UIColor(red: 0, green: 0.2, blue: 0.5, alpha: 1)
302
+
303
+ inoColor.setStroke()
304
+
305
+ ino.lineWidth = 4.4
306
+
307
+ ino.lineCapStyle = CGLineCap.round
308
+
309
+ ino.stroke()
310
+
311
+
312
+
313
+
314
+
315
+ arc2 = UIBezierPath(arcCenter: CGPoint(x:245, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat((M_PI)*4/5 - (M_PI)/2), clockwise: true)
316
+
317
+
318
+
319
+ let aColor2 = UIColor(red: 0, green: 0.5, blue: 1, alpha: 0.8)
320
+
321
+ aColor2.setStroke()
322
+
323
+ arc2.lineWidth = 4.4
324
+
325
+ arc2.lineCapStyle = CGLineCap.round
326
+
327
+
328
+
329
+ arc2.stroke()
330
+
331
+
332
+
333
+ let ino2 = UIBezierPath(arcCenter: CGPoint(x:245, y:350), radius: 40, startAngle: -1 * CGFloat ((M_PI)*4/5 + (M_PI)/2), endAngle: CGFloat(radian2) , clockwise: true)
334
+
335
+
336
+
337
+ let inoColor2 = UIColor(red: 0, green: 0.1, blue: 0.4, alpha: 1)
338
+
339
+ inoColor2.setStroke()
340
+
341
+ ino2.lineWidth = 4.4
342
+
343
+ ino2.lineCapStyle = CGLineCap.round
344
+
345
+ ino2.stroke()
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+ }
358
+
359
+
360
+
361
+ }
362
+
363
+ ```
364
+
103
365
  ##補足情報(言語/FW/ツール等のバージョンなど)
104
366
 
105
367
  xcode8 beta6

2

質問文章の改善

2016/09/09 10:20

投稿

mujika
mujika

スコア13

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- 具体的にはoverride func viewDidLoad()内のself.tou.isScrollEnabled = true を falseに変更したいです
9
+ 具体的には、遷移せずに同じ画面内に[UIViewでアニメーションするパラメータを作っており(これが他クラスです)]それをタッチするとスクロールが止まるという感じです。override func viewDidLoad()内のself.tou.isScrollEnabled = true を falseに変更したいです
10
10
 
11
11
 
12
12
 

1

タイトルのシンプル化

2016/09/08 11:45

投稿

mujika
mujika

スコア13

test CHANGED
@@ -1 +1 @@
1
- 他クラスからViewControlleroverride func viewDidLoad() 変更する方法がわかりません
1
+ 他クラスからViewControllerのviewDidLoadコード書き換える方法
test CHANGED
File without changes