2015-06-17 15 views
5

Ecco come ho chiamato l'UIView DraggableViewBackground in Obejective C e sta funzionando perfettamente, ma come fare lo stesso in SwiftCome chiamare initWithFrame di Objective C UIView a Swift

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

mio DraggableViewBackground è in Obiettivo C e voglio impostarlo come sottomenu al clic di un pulsante

risposta

7

dal UIView docs. Basta usare il normale inizializzatore rapido.

enter image description here

+0

Vuoi aggiungere un esempio, per favore (la teoria pura non è sufficiente). –

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

Questo dovrebbe fare il trucco.

È possibile cercare la differenza tra let e var per decidere cosa funziona meglio per le proprie esigenze in quel caso. let non può cambiare, var can.

+0

Grazie per l'aiuto e puoi dirmi cosa succede se initwithframe ha parametri aggiuntivi –

+0

Qualcosa come questo DraggableViewBackground (frame: self.view.frame, param1: something, param2: somethingElse) –

Problemi correlati