IMakk IMakk - 2 years ago 422
Objective-C Question

Focus UIcollectionView Cell TvOS

i'm new to tvos. I have created UIcollectionview using xib file in objective-c. how can i focus UIcollectionview cell.

i have label and imageview in collectionview cell. and i want to focus both label and imageview..

thanks in advance

Answer Source

UICollectionViewCell are not focus appearance by default, but you can achive this by adding one yourself.

- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
    if (self.focused)
        // Apply focused appearence,
        // e.g scale both of them using transform or apply background color 
       // Apply normal appearance


If you just want to focus ImageView like scaling it up when collection view cell get focus you can do like this in awakeFromNib method

self.imageView.adjustsImageWhenAncestorFocused = YES;
self.clipToBounds = NO;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download