I'm working on a tvOS project in swift and have a horizontally aligned UICollectionView
where each UICollectionViewCell
is a custom UIView consisting of a UIImageView
and a Label
below it. So my UICollectionView looks like this:
| UIImageView | | UIImageView |
| Label | | Label |
I also wanted the image to grow/shrink as the particular view gained and lost focus. In my collection view I added the code
func collectionView(collectionView: UICollectionView, canFocusItemAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
And in my custom cell class I have the line
imageView.adjustsImageWhenAncestorFocused = true;
So this somewhat works, although with 2 problems.
It seems all the views in the collection have a weird shadow under them, even when they're not focused. And then when they are focused, the image grows as expected, but it has another shadow under it. You can see what I mean here:
The first item in the collection has the focus
How do I get rid of them? I've tried all of these but none of them seem to work
contentView.layer.shadowOpacity = 0.0 // My imageView is a subview of this
contentView.layer.shadowColor = UIColor.clearColor().CGColor
imageView.layer.shadowOpacity = 0.0
imageView.layer.shadowColor = UIColor.clearColor().CGColor
It's not possible right now. I forwarded this question to Apple, and the response was: https://forums.developer.apple.com/message/105045#105045
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With