有没有办法在Apple tvOS TVML基础应用程序中使用自定义字体?我试过这个@font-face规则无济于事.
<document>
<head>
<style>
@font-face {
font-family: 'My Awesome Font';
font-weight: 600;
src: url("${this.BASEURL}/resources/fonts/awesome-font-bold.otf");
}
</style>
</head>
...
</document>
Run Code Online (Sandbox Code Playgroud) 我在探索tvOS,我发现,苹果提供了很好的一套模板使用写入TVML.我想知道tvOS使用TVML模板的应用程序是否也可以使用UIKit.
我可以在一个应用程序中混合使用UIKit和TVMLKit吗?
我在Apple开发者论坛上发现了一个帖子,但它没有完全回答这个问题,我正在通过文档找到答案.
有谁知道如何使用TVJS/TVML在Apple TV应用程序中动态生成模板?基本上我想点击我的API,获取一个对象数组,然后将这些数据插入到我的XML模板中.
我一直在寻找有关如何实现它的信息但是已经很短了.我发现许多教程使用硬编码图像,视频等,但没有动态生成.
任何帮助,将不胜感激.
我正在使用tvOS beta 3并尝试在tvml/tvjs方面做一些基本的调试.
通过我的js文件中的console.log(...)记录的消息不会出现在主Xcode输出窗口中.
是否有其他地方我可以找到这些消息或需要配置的设置?
gulp-uglify无法解释这段代码:
var alertString = `<?xml version="1.0" encoding="UTF-8" ?>
<document>
<alertTemplate>
<title>${title}</title>
<description>${description}</description>
</alertTemplate>
</document>`
Run Code Online (Sandbox Code Playgroud)
它抱怨这个角色:`.该角色对苹果的JS框架有效.我无法在uglify包中看到任何内容来忽略这些字符及其中的文本字符串.我错过了文档中的内容吗?
读者注意事项:这是一个很长的问题,但它需要一个背景来理解问题.
该颜色量化技术通常用于获取主色的图像.其中一个着名的色彩量化库是Leptonica通过修改的中值切割量化(MMCQ)和八叉树量化(OQ) Github的Color-thief by @lokesh是一个非常简单的MMCQ算法JavaScript实现:
var colorThief = new ColorThief();
colorThief.getColor(sourceImage);
Run Code Online (Sandbox Code Playgroud)
从技术上讲,<img/>HTML元素上的图像支持在一个<canvas/>元素上:
var CanvasImage = function (image) {
this.canvas = document.createElement('canvas');
this.context = this.canvas.getContext('2d');
document.body.appendChild(this.canvas);
this.width = this.canvas.width = image.width;
this.height = this.canvas.height = image.height;
this.context.drawImage(image, 0, 0, this.width, this.height);
};
Run Code Online (Sandbox Code Playgroud)
TVML正如我们稍后将看到的那样,这就是问题所在.
我最近发现的另一个实现与本文相关联使用imagemagick,awk和kmeans来查找链接到使用python生成令人敬畏的linux桌面主题的图像中的主色.作者发表了一篇关于使用python和k-means来查找在那里使用的图像中的主色的文章(抱歉所有这些链接,但我正在追溯我的历史......).
作者非常高效,并添加了一个我在这里发布的JavaScript版本:使用JavaScript和k-means来查找图像中的主色
在这种情况下,我们正在生成图像的主色,而不是使用MMCQ(或OQ)算法,而是使用K-Means.问题是图像必须是一个:
<canvas id="canvas" style="display: none;" width="200" height="200"></canvas>
Run Code Online (Sandbox Code Playgroud)
然后
function …Run Code Online (Sandbox Code Playgroud) 是否可以加载和使用外部JavaScript库以用于TVML Apple TV应用程序?
例如,我可以加载Firebase js库并使用它来获取数据吗?或者加载lodash来使用它的功能?
我正在使用 Apple 的 TVMLCatalog 示例文件,但一直试图将对象传递到我在演示器中加载的模板文件(javascript 文件)。这看起来应该是一个完全基本的事情来完成,但它让我击败了。
我有以下内容,它使用资源加载器加载模板,并将其推送到视图。
resourceLoader.loadResource('http://localhost/mytemplate.xml.js',
function(resource) {
if (resource) {
var doc = self.makeDocument(resource);
doc.addEventListener("select", self.load.bind(self));
navigationDocument.pushDocument(doc);
}
}
);
Run Code Online (Sandbox Code Playgroud)
当模板文件加载到视图中时,我在哪里定义一个对象或设置一个将在文档中的变量?
在下面的委托函数中,我试图做但没有得到想要的结果
override func didUpdateFocusInContext(context: UIFocusUpdateContext,withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
if (context.nextFocusedView == self) {
coordinator.addCoordinatedAnimations({ () -> Void in
self.animationDidStop(CAAnimation(), finished: true)
}, completion: { () -> Void in
})
}
else {
// handle unfocused appearance changes
coordinator.addCoordinatedAnimations({ () -> Void in
self.animationDidStop(CAAnimation(), finished: true)
}, completion: { () -> Void in
})
}
context.nextFocusedView?.layer.shadowOffset = CGSizeZero
context.nextFocusedView?.layer.shadowOpacity = 0.9;
context.nextFocusedView?.layer.shadowRadius = 0;
context.nextFocusedView?.layer.shadowColor= UIColor.orangeColor().CGColor
context.previouslyFocusedView?.layer.shadowOpacity = 0;
}
Run Code Online (Sandbox Code Playgroud) 我从Apple下载了TVMLCatalog应用程序.代码分为两部分.
我正在尝试将客户端 TVJS文件托管在与TVMLCatalog项目相同的包中.
我已经改变了AppDelegate didFinishLaunching如下:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
/*
Create the TVApplicationControllerContext for this application
and set the properties that will be passed to the `App.onLaunch` function
in JavaScript.
*/
let appControllerContext = TVApplicationControllerContext()
/*
The JavaScript URL is used to create the JavaScript context for your
TVMLKit application. Although it is …Run Code Online (Sandbox Code Playgroud) tvml ×10
tvos ×9
apple-tv ×4
tvjs ×3
javascript ×2
gulp ×1
gulp-uglify ×1
quantization ×1
swift ×1
uikit ×1
xcode ×1