簡體   English   中英

Swift 中的橋接標頭轉換

[英]Bridging header conversion in Swift

如何將這種 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

你可以試試這個。 替換為您的frame

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM