如何在iPhone,iOS 8上为popover设置动画

时间:2015-03-19 22:20:22

标签: ios swift uipopovercontroller popover

我有一个弹出窗口显示按钮点击,但它没有动画。我希望它以零大小开始,并且增长到与帖子上的facebooks胡萝卜动作类似的正确大小。非常感谢任何帮助。代码如下:

@IBAction func button(sender: AnyObject) {
    let popover = PopoverController()
    popover.modalPresentationStyle = .Popover
    popover.preferredContentSize = CGSizeMake(UIScreen.mainScreen().bounds.width, 100)

    let popoverPresentationController = popover.popoverPresentationController
    popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.Up
    popoverPresentationController?.delegate = self
    popoverPresentationController?.sourceView = sender as UIView
    popoverPresentationController?.sourceRect = sender.bounds

    self.presentViewController(popover, animated: true, completion: nil)
}


func adaptivePresentationStyleForPresentationController(controller: UIPresentationController!) -> UIModalPresentationStyle {
        return UIModalPresentationStyle.None
}

1 个答案:

答案 0 :(得分:0)

您可以尝试

popoverPresentationController?.modalTransitionStyle = .crossDissolve 

在演示之前。