2012-09-19 22:06:30 +04:00
|
|
|
using System;
|
2015-01-19 18:09:40 +03:00
|
|
|
using CoreGraphics;
|
2012-09-19 22:06:30 +04:00
|
|
|
|
2015-01-19 18:09:40 +03:00
|
|
|
using UIKit;
|
|
|
|
using Foundation;
|
|
|
|
using CoreAnimation;
|
2012-09-19 22:06:30 +04:00
|
|
|
|
|
|
|
namespace PinchIt
|
|
|
|
{
|
|
|
|
public class PinchLayout : UICollectionViewFlowLayout
|
|
|
|
{
|
|
|
|
float pinchedCellScale;
|
2015-01-19 18:09:40 +03:00
|
|
|
CGPoint pinchedCellCenter ;
|
2012-09-19 22:06:30 +04:00
|
|
|
public NSIndexPath pinchedCellPath { get; set; }
|
|
|
|
|
|
|
|
public void applyPinchToLayoutAttributes (UICollectionViewLayoutAttributes layoutAttributes)
|
|
|
|
{
|
|
|
|
if (layoutAttributes.IndexPath.Equals (pinchedCellPath)) {
|
|
|
|
layoutAttributes.Transform3D = CATransform3D.MakeScale (pinchedCellScale, pinchedCellScale, 1.0f);
|
|
|
|
layoutAttributes.Center = pinchedCellCenter;
|
|
|
|
layoutAttributes.ZIndex = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-19 18:09:40 +03:00
|
|
|
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect (CGRect rect)
|
2012-09-19 22:06:30 +04:00
|
|
|
{
|
|
|
|
var array = base.LayoutAttributesForElementsInRect (rect);
|
|
|
|
|
|
|
|
foreach (var cellAttributes in array)
|
|
|
|
applyPinchToLayoutAttributes (cellAttributes);
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2012-09-19 22:06:30 +04:00
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override UICollectionViewLayoutAttributes LayoutAttributesForItem (NSIndexPath indexPath)
|
|
|
|
{
|
|
|
|
var attributes = base.LayoutAttributesForItem(indexPath);
|
|
|
|
|
|
|
|
applyPinchToLayoutAttributes (attributes);
|
|
|
|
|
|
|
|
return attributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPinchedCellScale (float scale)
|
|
|
|
{
|
|
|
|
pinchedCellScale = scale;
|
|
|
|
InvalidateLayout();
|
|
|
|
}
|
|
|
|
|
2015-01-19 18:09:40 +03:00
|
|
|
public void setPinchedCellCenter (CGPoint origin)
|
2012-09-19 22:06:30 +04:00
|
|
|
{
|
|
|
|
pinchedCellCenter = origin;
|
|
|
|
InvalidateLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|