0

I've created some UICollectionViewCells which I'd like to place inside a UICollectionView with the option for the user to set the size of the items in the view (between 100% and 50% so they can see more UIViews at the same time).

So I've added a function like so:

    [Export("collectionView:layout:sizeForItemAtIndexPath:")]
    public CGSize GetSizeForItem(UICollectionView collectionView, UICollectionViewLayout layout, NSIndexPath indexPath)
    {
        return new CGSize {
            Width = 243.0f,
            Height = 209.7f
        };
    }

Where 243.0f/209.7f is the size of the UICollectionViewCell.

My particular instance of UICollectionViewCell has a few text fields and things inside of it, so setting a smaller CG size (i.e. *0.5) causes a few text issues.

I've found that using scaling with CGAffineTransform leads to a desirable result however when I apply the scale to the individual child views it doesn't carry over to the UICollectionView for alignment (which makes sense).

Is there a way around this where I can use transform scaling to achieve my desired result?

I'm thinking maybe I should create a container like UICollectionViewCell where its child is the actual view I want to display, then set its size inversely to the parents size and apply scale to achieve the correct result...

meds
  • 21,699
  • 37
  • 163
  • 314
  • I think, you can solve the text issue and use sizeForItemAtIndexPath method. It is correct way. – Andrew Romanov Nov 17 '16 at 04:20
  • how is it supposed to work though? The font sizes do not change on there own and I'm not sure how to get a nice font scale going on based on the size of the uiview... – meds Nov 17 '16 at 04:36
  • here http://stackoverflow.com/questions/2396715/how-to-figure-out-the-font-size-of-a-uilabel-when-adjustsfontsizetofitwidth-is you can find solution for font. – Andrew Romanov Nov 17 '16 at 04:49
  • In iOS there many fields there you should do all work by hans. – Andrew Romanov Nov 17 '16 at 04:52

0 Answers0