在 html 嵌入字符串中连接 swift 个变量

concatenate swift variables in html embedded string

标题不是很清楚我知道让我解释一下。我在 UIWebView 上显示一些 vimeo 视频。现在我正在使用这段代码来使事情正常进行:

    let embedHTML="<html><head><style type=\"text/css\">body {background-color: transparent;color: white;}</style></
    head><body style=\"margin:0\"><iframe src=\"//player.vimeo.com/video/171151492?autoplay=1&amp;loop=1\"
    width=\"266\"height=\"105\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";

现在它说的是:width=\"266\"height=\"105\" 我想输入:

self.webView.frame.width

而不是 266 和

self.webView.frame.height

而不是 105

我该怎么做?我的意思是我知道如何使用 + 连接字符串,但这是很难的方式,它没有用。有人有什么想法吗?

let oneVar = self.webView.frame.width
let anotherVar = self.webView.frame.height

然后:

let embedHTML = "<html><head><style type=\"text/css\">body {background-color: transparent;color: white;}</style></
    head><body style=\"margin:0\"><iframe src=\"//player.vimeo.com/video/171151492?autoplay=1&amp;loop=1\"
    width=\"\(oneVar)\"height=\"\(anotherVar)\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";