Ios 如何在Swift中调用initWithFrame的Objective UIView
这就是我在OBJECTIVE C中调用UIViewDragableViewBackground的方式,它工作得很好,但在Swift中如何实现同样的功能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中 我想在单击菜单中的按钮时将其设置为子视图。只需使用
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)请您添加一个示例(纯理论是不够的)。