[英]Define custom frame of UIViewController or UIView
I'm doing a game in Swift 2.0 & iOS >= 8 in which I have the initial VC hosting the SKScene that manages the game itself. 我正在使用Swift 2.0和iOS> = 8进行游戏,在该游戏中,我有初始的VC托管着SKScene来管理游戏本身。
When the player wins or loses, I want to show a message as below : 当玩家赢或输时,我要显示以下消息:
I show this message through another VC loaded from the interface builder with the below code called from the initial VC class : 我通过接口构建器加载的另一个VC显示此消息,并使用以下代码从初始VC类调用:
let VCWin = self.storyboard!.instantiateViewControllerWithIdentifier("WinVC") as! WinVC
VCWin.modalPresentationStyle = UIModalPresentationStyle.FormSheet
VCWin.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve
self.presentViewController(VCWin, animated: true, completion: nil)
It is important that WinVC allows to see what is behind dimmed as FormSheet & CrossDissolve properties enable to do. WinVC允许看到FormSheet和CrossDissolve属性启用后变暗的原因很重要。
WinVC will also host a view that presents a SKScene which does some sprite animations. WinVC还将主持一个视图,该视图呈现一个SKScene,该场景可以执行一些精灵动画。
My problem is to remove the white parts near the rounded yellow corners in order to see what is behind (like the rest of the screen that is dimmed). 我的问题是删除圆的黄色角附近的白色部分,以查看后面的内容(例如屏幕其余部分变暗)。
Is it possible to set the frame of a VC to the mask of the image used here ? 是否可以将VC的帧设置为此处使用的图像的遮罩? or to set the frame of a view to the mask of the image used and have the VC below transparent ? 还是将视图的框架设置为所用图像的遮罩,并使VC透明以下?
I have removed everything from WinVC to avoid having issues caused by other parts of the code 我已从WinVC中删除了所有内容,以避免由于代码的其他部分引起问题
class WinVC: UIViewController
{
override func viewDidLoad()
{
super.viewDidLoad()
}
override func viewDidAppear(animated: Bool)
{
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)
{
for _ in touches
{
self.dismissViewControllerAnimated(false, completion: nil)
}
}
override func viewDidDisappear(animated: Bool)
{
}
}
Also the setup in the interface builder : 也是界面生成器中的设置:
VC Setup VC设置
view Setup 查看设置
Image Setup 影像设定
Your frame is fine - It's probably because your UIViewController
contains a view object, that has a white background. 您的框架很好-可能是因为UIViewController
包含一个具有白色背景的视图对象。 In your WinVC
class's viewDidLoad
, do this: 在WinVC
类的viewDidLoad
,执行以下操作:
view.backgroundColor = UIcolor.clearColor()
I solved my issue with the following solution : 我通过以下解决方案解决了我的问题:
Then I have the wanted result : 然后我有想要的结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.