Closed btc closed 7 years ago
For example, on the Now Playing screen:
func incoming(info: NowPlayingInfo, forStation station: Station) {
// BUG: If user taps station and immediately taps the Miniplayer to open
// this screen, the screen appears without any content. What in the world
// is happening?
let p = TwoLinePresenter(forInfo: info)
titleView.text = p.title
artistView.text = p.subtitle
if info.artwork.isPresent(), let c = info.artwork.dominantUIColor() {
let s = imageView.frame.size
let placeholder = UIImage.from(color: c, withSize: s)
guard let str = info.artwork.url500, let url = URL(string: str) else {
imageView.image = playbackManager?.station?.image
return
}
imageView.af_setImage(withURL: url, placeholderImage: placeholder)
} else {
imageView.image = playbackManager?.station?.image
}
}
IMO bounds.size == frame.size. frame is location of the view in the superviews coordinate system, where bounds is a window into content of the view.
bounds.x / bounds.y is not 0 or 0 in Scrollviews.
bounds.size == frame.size
is not always correct. If you apply a transform to the view, the frame size is all messed up. As a general rule, it is best to use center and bounds, instead of frame.
The bounds origin tell the underlaying layer what portion of the contents to draw. A scroll view uses the bounds origin to manage what gets drawn as the user scrolls.
Here's a helpful resource I just found.
Excellent indeed! As usual, Stanford lectures are top notch.
It's still not clear to me when to use which.