如何获得自定义尺寸的演示模式?尝试了许多不同的解决方案,其中许多似乎过时了
这是我从父视图控制器实例化模态视图的方法:
Sub Create_New_Excel_and_Disable_Properties()
'<~ Declare and prepare the new application
Dim NewExcel As Excel.Application
Set NewExcel = New Excel.Application
'<~ declare and set the workbook variable
Dim ExcelWbk As Excel.Workbook
Set ExcelWbk = NewExcel.Workbooks.Open("folder\template.xlsx")
'<~ call the sub that disables the Application.properties
OPTIMIZE_VBA False, NewExcel
End Sub
但是,模态视图覆盖全屏而不是仅占用100 * 100。
答案 0 :(得分:1)
您需要实施UIViewControllerTransitioningDelegate
方法和UIViewControllerAnimatedTransitioning
方法来自定义显示的UIViewController
尺寸。
要知道如何实现自定义动画师,
请参阅:https://github.com/pgpt10/Custom-Animator
修改强>
class ViewController: UIViewController
{
//MARK: Private Properties
fileprivate let animator = Animator()
//MARK: View Lifecycle Methods
override func viewDidLoad()
{
super.viewDidLoad()
}
override func awakeFromNib()
{
super.awakeFromNib()
self.transitioningDelegate = self
self.modalPresentationStyle = .custom
}
//MARK: Button Action Methods
@IBAction func dismissController(_ sender: UIButton)
{
self.dismiss(animated: true, completion: nil)
}
}
// MARK: - UIViewControllerTransitioningDelegate Methods
extension ViewController : UIViewControllerTransitioningDelegate
{
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
self.animator.transitionType = .zoom
self.animator.size = CGSize(width: 100, height: 100)
return self.animator
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
return self.animator
}
}