2016-05-15 4 views
0

私は別のスレッドを使うのが初めてです。私はこれを間違ったと思う。私はこのアニメーションを起こさせようとしていますが、起こっている間にユーザーがページとやりとりできるようにしています。ここでスウィフトは別のスレッドでもページとやりとりできません

は私のコードは

ある
let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT 
    dispatch_async(dispatch_get_global_queue(priority, 0)) { 
     UIView.animateWithDuration(3.0, animations: { 
      self.backgroundView.layer.backgroundColor = UIColor(red: 25.0/255.0, green: 25.0/255.0, blue: 25.0/255.0, alpha: 1.0).CGColor 
     }) 

     dispatch_async(dispatch_get_main_queue()) { 
      self.backgroundView.layer.backgroundColor = UIColor(red: 25.0/255.0, green: 25.0/255.0, blue: 25.0/255.0, alpha: 1.0).CGColor 
     } 
    } 
+4

メインスレッドでアニメーションを実行する必要があります。ユーザーとの対話を許可する場合は、 'animationWithDuration:delay:options:animations:completions:'で '.AllowUserInteraction'オプションを使用してください。 – Rob

+0

ありがとうございました!働いた! – RubberDucky4444

答えて

0

答えを@Robをお願い致します。

アニメーションはメインスレッドで行う必要があります。ユーザーとのやりとりを許可するには、animationWithDuration:delay:options:animations:completionsの.AllowUserInteractionオプションを使用します。

関連する問題