Swift - 桥接头转换

时间:2015-01-14 03:05:19

标签: ios objective-c swift xcode6

如何将此Objective-C格式转换为swift?我已经创建了一个名为Bridging-Header.h

的桥接头

我已将此库标头导入桥接标题。

#import "DraggableView.h"
#import "DraggableViewBackground.h"
#import "OverlayView.h"

然后我想将这个目标-C事物转换成swift。

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

到目前为止我已经完成的工作,我在DraggableViewBackground中的DraggableViewBackground.h调用了对象ViewController.swift

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.

        var instanceOfDraggableViewBackground: DraggableViewBackground = DraggableViewBackground()

    }
}

请指教。谢谢。

参考图书馆:https://github.com/cwRichardKim/TinderSimpleSwipeCards

1 个答案:

答案 0 :(得分:0)

你可以试试这个。替换为frame

var draggable = DraggableViewBackground(frame: CGRectMake(0, 0, 100, 100))
self.view.addSubview(draggable)
相关问题