2017-08-03 117 views
0

enter image description here如何使用Swift 3將圖像應用於圖像?

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { 
    let touchesSet = touches as NSSet 
    let touch = touchesSet.anyObject() as? UITouch 
    let location = touch?.location(in: self.view) 
    if touch!.view == bee1 { 
     bee1?.center = location! 
    } else if touch!.view == bee2 { 
     bee2?.center = location! 
    } 
} 

我需要代碼,這個遊戲爲iOS,用斯威夫特;但我不知道如何使用Swift將圖像應用到圖像上。我迄今爲止的嘗試都失敗了; touch!.view!=圖片

+0

使用手勢或使用按鈕和應用圖像到該按鈕 – Joe

+0

嘗試添加「用戶交互啓用「給你的蜜蜂圖像。 – Pochi

+0

你究竟想達到什麼目的? – PGDev

回答

0

我認爲你需要使用手勢和設置圖像userInteractionEnabled =真 OBJ-C:

self.imageView.userInteractionEnabled = YES; 
UITapGestureRecognizer * tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapImageView:)]; 
tap.delegate= self; 
[self.imageView addGestureRecognizer:tap]; 
相關問題