PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 28, 2022

[FIXED] How do I remove the focus shadows from a UIView in a UICollectionView in swift?

 September 28, 2022     swift, tvos, uicollectionview, uiview, xcode     No comments   

Issue

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:

this screenshot

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

Solution

It's not possible right now. I forwarded this question to Apple, and the response was: https://forums.developer.apple.com/message/105045#105045



Answered By - JackPearse
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing