查看这个线程并将代码转换为接受的答案,这就是我得到的:
var dialog: UIAlertView = UIAlertView(title: "Title", message: "Message:", delegate: self, cancelButtonTitle: "Cancel", otherButtonTitles: "Done", nil)
dialog.alertViewStyle = UIAlertViewStylePlainTextInput
dialog.show()
var dillusionView: UIView = UIView(frame: CGRectMake(0, 0, view.frame.size.width, view.frame.size.height))
dillusionView.backgroundColor = UIColor.blackColor()
view.addSubview(dillusionView)
UIView(duration: 1.0, delay: 0.0, options: UIViewKeyframeAnimationOptionAutoreverse | UIViewKeyframeAnimationOptionRepeat, animations: { UIView(relativeStartTime: 0.0, relativeDuration: 0.5, animations: { dialog.window.transform = CGAffineTransformTranslate(dialog.transform, dialog.frame.origin.x - 10, dialog.frame.origin.y)
})
UIView(relativeStartTime: 0.5, relativeDuration: 0.5, animations: { dialog.window.transform = CGAffineTransformTranslate(dialog.transform, dialog.frame.origin.x + 10, dialog.frame.origin.y)
})
}, completion: nil)
作为警告,此代码中可能存在一些错误。希望能帮助到你!