【发布时间】:2014-03-06 07:49:20
【问题描述】:
将UIButton 添加到SKScene 的最佳方法是什么?
我意识到我可能无法将它添加为场景的子视图,那么有什么替代方法可以在场景顶部有一个可点击的按钮?
【问题讨论】:
-
UIKit 视图被(只能)添加到 SKView,而不是场景或其他节点
标签: ios objective-c uikit sprite-kit skscene
将UIButton 添加到SKScene 的最佳方法是什么?
我意识到我可能无法将它添加为场景的子视图,那么有什么替代方法可以在场景顶部有一个可点击的按钮?
【问题讨论】:
标签: ios objective-c uikit sprite-kit skscene
/// create a uibutton in skscene (spritkit)
UIButton * startButton = [[UIButton alloc]initWithFrame:CGRectMake(100, 200, 60, 20)];
startButton.backgroundColor = [UIColor redColor];
[self.view addSubview:startButton];
/// if u want to connect it to a method or function ///
[startButton addTarget:self action:@selector(StartBtn) forControlEvents:UIControlEventTouchUpInside];
【讨论】: