How to call initWithFrame Objective-C UIView in Swift

This is what I called the UIView DraggableViewBackground in Obejective C, and it works fine, but how to do the same in Swift

DraggableViewBackground *draggableBackgroundforurl = [[DraggableViewBackground alloc]initWithFrame:self.view.frame]; 

My DraggableViewBackground is in Objective-C and I want to set this as a sub-item at the click of a button

+5
source share
2 answers
 let draggableBackgroundforurl = DraggableViewBackground(frame: self.view.frame); 

That should do the trick.

You can find the difference between let and var to decide what works best for your needs in this case. let cannot change; var can.

+8
source

From UIView docs . Just use a regular quick initializer.

enter image description here

+7
source

All Articles