我从我的网络服务
获得这样的内容<Strong>some unicode characters</Strong>
<iframe src="https://www.youtube.com/embed/<some_ID>" width="640" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
当我将此字符串直接加载到UIWebView
时,它是黑色的。但我想把它变成白色。
UIView
宽度我该怎么做?
答案 0 :(得分:0)
您可以使用Javascript添加一些样式并调整视频大小:
<Window x:Class="BlueGearAPP.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BlueGearAPP"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<StackPanel x:Name="stkSPanel"></StackPanel>
</ScrollViewer>
override func viewDidLoad() {
super.viewDidLoad()
let html = "..."
webView.delegate = self
webView.loadHTMLString(html, baseURL: nil)
}
func webViewDidFinishLoad(webView: UIWebView) {
let url = NSBundle.mainBundle().URLForResource("script", withExtension: "js")!
let javascript = try! String(contentsOfURL: url)
webView.stringByEvaluatingJavaScriptFromString(javascript)
}
的内容:
script.js