【发布时间】:2016-05-19 07:45:45
【问题描述】:
当我收到来自 parse 的通知时,我正在尝试显示自定义视图。 这个视图用一个动画显示,它用另一个动画隐藏。这个视图还有一个 uitapgesturerecognizer,当用户点击视图时需要触发它。 我的问题是,当第二个动画被触发时,自定义视图的 uitapgesture 不起作用:\
有什么想法吗?我粘贴代码。 谢谢!
func doManageObjectNotification(notification: COPushNotification){
mainView = UIApplication.sharedApplication().keyWindow!
customView = CustomNotificationView()
let height = customView.calculateViewHeight()
customView.frame = CGRectMake(0, -height, mainView.frame.width, height)
customView.targetMethod = notificationWasTapped
customView.setContent(notification)
customView.alpha = 0
mainView.addSubview(customView)
UIView.animateWithDuration(0.75, delay: 0, options: [UIViewAnimationOptions.CurveEaseInOut, UIViewAnimationOptions.AllowUserInteraction], animations: { () -> Void in
// Show the view
self.customView.frame.origin.y = 0
self.customView.alpha = 1
}) { (Bool) -> Void in
UIView.animateWithDuration(0.75, delay: 5, options: [UIViewAnimationOptions.CurveEaseInOut, UIViewAnimationOptions.AllowUserInteraction], animations: {
// Hide the view
self.customView.alpha = 0
}, completion: { finished in
self.customView.removeFromSuperview()
self.customView = nil
})
}
}
【问题讨论】:
标签: ios swift uiviewanimation uitapgesturerecognizer