Using Tvposterimage in Tvuikit for Tvos 12

Using TVPosterImage in TVUIKit for tvOS 12

Eventually I managed to make it working programmatically. I tested both TVPosterView and TVMonogramView (basically a round button). The following code works with Xcode 10 beta 5, on tvOS 12 beta 5:

Swift 4.2

import UIKit
import TVUIKit

class SecondViewController: UIViewController {

var myPoster = TVPosterView()
var myMonogram = TVMonogramView()

override func viewDidLoad() {
super.viewDidLoad()

myPoster.frame = CGRect(x: 100, y: 100, width: 550, height: 625)
myPoster.image = UIImage(named: "image1.png")
myPoster.imageView.masksFocusEffectToContents = true
myPoster.title = "Poster"
myPoster.subtitle = "This is the poster subtitle"

self.view.addSubview(myPoster)

var myName = PersonNameComponents()
myName.givenName = "Michele"
myName.familyName = "Dall'Agata"

myMonogram.frame = CGRect(x: 700, y: 100, width: 500, height: 475)
myMonogram.image = UIImage(named: "image2.png")
myMonogram.title = "Monogram"
myMonogram.subtitle = "This is the Monogram subtitle"
myMonogram.personNameComponents = myName

self.view.addSubview(myMonogram)

print(myMonogram.personNameComponents)
}
}

I didn't manage to scale the poster's image with scaleAspectFit, though. Also my first image was rounded with a transparency, and only choosing a frame size that perfectly fit the squared image plus the titles (so no aspect fit needed), the glowing effect became transparent on the corners. Otherwise the whole image was opaque, using its own (quite small) rounded corners.

How to use MarqueeLabel in Swift?

I used this little piece of code for my label to scroll like marquee:

@IBOutlet weak var firstLabel: UILabel! 
override func viewDidLoad() {
super.viewDidLoad()

UIView.animateWithDuration(12.0, delay: 1, options: ([.CurveLinear, .Repeat]), animations: {() -> Void in
self.firstLabel.center = CGPointMake(0 - self.firstLabel.bounds.size.width / 2, self.firstLabel.center.y)
}, completion: { _ in })
}

Yes, it worked.



Related Topics



Leave a reply



Submit