IMakk IMakk - 11 months ago 344
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


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;