【问题标题】:Bridging header conversion in SwiftSwift 中的桥接头转换
【发布时间】:2015-01-14 03:05:18
【问题描述】:

如何将这种 Objective-C 格式转换为 Swift?我已经创建了一个名为 Bridging-Header.h 的桥接头。

我已经将这个库头导入到桥接头中。

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

那我想把这个Objective-C的东西转成swift。

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

到目前为止我已经做了什么,我在我的ViewController.swift 中从DraggableViewBackground.h 调用对象DraggableViewBackground

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

【问题讨论】:

    标签: ios objective-c swift xcode6 bridging-header


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-08
      • 2019-09-03
      • 2014-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多