2017-08-03 116 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]; 
相关问题