Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在Swift中调用initWithFrame的Objective UIView_Ios_Swift_Uiview - Fatal编程技术网

Ios 如何在Swift中调用initWithFrame的Objective UIView

Ios 如何在Swift中调用initWithFrame的Objective UIView,ios,swift,uiview,Ios,Swift,Uiview,这就是我在OBJECTIVE C中调用UIViewDragableViewBackground的方式,它工作得很好,但在Swift中如何实现同样的功能 DraggableViewBackground *draggableBackgroundforurl = [[DraggableViewBackground alloc]initWithFrame:self.view.frame]; 我的DragableViewBackground在目标C中 我想在单击菜单中的按钮时将其设置为子视图。只需使用

这就是我在OBJECTIVE C中调用UIViewDragableViewBackground的方式,它工作得很好,但在Swift中如何实现同样的功能

 DraggableViewBackground *draggableBackgroundforurl = [[DraggableViewBackground alloc]initWithFrame:self.view.frame];
我的DragableViewBackground在目标C中 我想在单击菜单中的按钮时将其设置为子视图。只需使用普通的swift初始值设定项

let draggableBackgroundforurl = DraggableViewBackground(frame: self.view.frame);

这应该能奏效


您可以查找
let
var
之间的差异,以确定在这种情况下什么最适合您的需要
let
不能更改,
var
可以。

谢谢您的帮助,您能告诉我如果initwithframe有额外的参数怎么办像这样的方法DragableViewBackground(frame:self.view.frame,param1:something,param2:somethingles)请您添加一个示例(纯理论是不够的)。