角度RSS提要显示

时间:2017-09-07 12:05:38

标签: css angular rss

我想将rss feed调用到我成功进行API调用的新闻栏,但我坚持如何精美地显示它们。更具体地说,我希望新闻提要从右向左逐个自动滚动,直到我的提要数组结束,然后它再次无限启动。

这就是我得到的: enter image description here

这就是我想要的(突发新闻自动滚动条):

http://cdn.fearlessflyer.com/wp-content/uploads/2012/11/hades-home.gif

以下是我的代码:

模板:

import Foundation
import UIKit
import ImageIO
import MobileCoreServices

extension UIImage {
    static func animatedGif(from images: [UIImage]) {
        let fileProperties: CFDictionary = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: 0]]  as CFDictionary
        let frameProperties: CFDictionary = [kCGImagePropertyGIFDictionary as String: [(kCGImagePropertyGIFDelayTime as String): 1.0]] as CFDictionary

        let documentsDirectoryURL: URL? = try? FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
        let fileURL: URL? = documentsDirectoryURL?.appendingPathComponent("animated.gif")

        if let url = fileURL as CFURL? {
            if let destination = CGImageDestinationCreateWithURL(url, kUTTypeGIF, images.count, nil) {
                CGImageDestinationSetProperties(destination, fileProperties)
                for image in images {
                    if let cgImage = image.cgImage {
                        CGImageDestinationAddImage(destination, cgImage, frameProperties)
                    }
                }
                if !CGImageDestinationFinalize(destination) {
                    print("Failed to finalize the image destination")
                }
                print("Url = \(fileURL)")
            }
        }
    }
}

提前谢谢。

编辑 :我找到了一种解决方法,只使用CSS动画以我想要的方式显示新闻标题。

newsbar.component.css:

  <div class="container content-secondary">
  <div class="news-bar">
    <div class="ticker-wrap">
      <div class="ticker">
        <span *ngFor="let new of news" class="ticker__item">
            <a href="{{new.link}}" target="_blank">{{new.title}}</a>
        </span>
      </div>
    </div>
  </div>
</div>

0 个答案:

没有答案