快速

时间:2016-06-24 00:47:00

标签: html ios css swift uiwebview

我从我的网络服务

获得这样的内容
<Strong>some unicode characters</Strong>
<iframe src="https://www.youtube.com/embed/<some_ID>" width="640" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>

当我将此字符串直接加载到UIWebView时,它是黑色的。但我想把它变成白色。

  1. 如何在swift
  2. 中更改此颜色
  3. 还需要将此视频的宽度更改为当前UIView宽度
  4. 我该怎么做?

1 个答案:

答案 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