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
Check If an Int Value Is Greater or Equal to Another Int? Value
How to Ensure Make Sure I'm Not Accessing Data Until It's Loaded In
Making Gradient Background in Swift - the Right Way
How to Pass a Local Function to Another Object During Init
How to Deal with Commas When Writing Objects to CSV in Swift
Nsattributedstring and Emojis: Issue with Positions and Lengths
Check Whether the Arreferenceimage Is No Longer Visible in the Camera's View
Receiving Data from Nsinputstream in Swift
How to Procedurally Draw Rectangle/Lines in Swift Using Cgcontext
Getting Pixel Format from Cgimage
Accessing Struct from One Class to Another
How to Inject .Environmentobject() in Watchos6
How to Decrease a Value Using Fieldvalue in Firestore (Swift)
Swift Access Array with Index Gives Following Error. Any Idea Why
How to Change the Appearance of the Datepicker in the Swiftui Framework to Only Months and Years
Cannot Preview This File, App May Have Crashed -- Occurs When Inputting Specific Line of Code
Rotation Gesture Produces Undesired Rotation
Using Reflection to Set Object Properties Without Using Setvalue Forkey