本文整理汇总了C#中UIView.ResizableSnapshotView方法的典型用法代码示例。如果您正苦于以下问题:C# UIView.ResizableSnapshotView方法的具体用法?C# UIView.ResizableSnapshotView怎么用?C# UIView.ResizableSnapshotView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIView
的用法示例。
在下文中一共展示了UIView.ResizableSnapshotView方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnimateTransition
public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext,
UIViewController fromViewController, UIViewController toViewController,
UIView fromView, UIView toView)
{
UIView containerView = transitionContext.ContainerView;
containerView.AddSubview (toView);
containerView.SendSubviewToBack (toView);
var size = toView.Frame.Size;
var snapshots = new List<UIView> ();
float xFactor = 10f;
float yFactor = xFactor * size.Height / size.Width;
for (float x = 0; x < size.Width; x += size.Width / xFactor) {
for (float y = 0; y < size.Height; y += size.Height / yFactor) {
var snapshotRegion = new RectangleF (x, y, size.Width / xFactor, size.Height / yFactor);
UIView snapshot = fromView.ResizableSnapshotView (snapshotRegion, false, UIEdgeInsets.Zero);
snapshot.Frame = snapshotRegion;
containerView.AddSubview (snapshot);
snapshots.Add (snapshot);
}
}
containerView.SendSubviewToBack (fromView);
var rnd = new Random ();
double duration = TransitionDuration (transitionContext);
NSAction action = () => {
foreach (UIView view in snapshots) {
float xOffset = rnd.Next (-100, 100);
float yOffset = rnd.Next (-100, 100);
view.Frame = new RectangleF (view.Frame.X + xOffset, view.Frame.Y + yOffset, view.Frame.Width, view.Frame.Height);
view.Alpha = 0f;
var transition = CGAffineTransform.MakeRotation (rnd.Next (-10, 10));
transition.Scale (0f, 0f);
view.Transform = transition;
}
};
UIView.Animate (duration, action, () => {
foreach (UIView view in snapshots)
view.RemoveFromSuperview ();
transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
});
}
示例2: CreateSnapshots
private List<UIView> CreateSnapshots (UIView view, bool afterScreenUpdates)
{
UIView containerView = view.Superview;
var snapshotRegion = new CGRect (0, 0, view.Frame.Size.Width / 2, view.Frame.Size.Height);
UIView leftHandView = view.ResizableSnapshotView (snapshotRegion, afterScreenUpdates, UIEdgeInsets.Zero);
leftHandView.Frame = snapshotRegion;
containerView.AddSubview (leftHandView);
snapshotRegion = new CGRect (view.Frame.Size.Width / 2, 0, view.Frame.Size.Width / 2, view.Frame.Size.Height);
UIView rightHandView = view.ResizableSnapshotView (snapshotRegion, afterScreenUpdates, UIEdgeInsets.Zero);
rightHandView.Frame = snapshotRegion;
containerView.AddSubview (rightHandView);
containerView.SendSubviewToBack (view);
return new List<UIView> () { leftHandView, rightHandView };
}
示例3: CreateSnapshot
private UIView CreateSnapshot(UIView view, bool afterUpdates, float offset, bool left)
{
CGSize size = view.Frame.Size;
UIView containerView = view.Superview;
float foldWidth = (float)(size.Width * 0.5f / Folds);
UIView snapshotView;
if (!afterUpdates) {
// create a regular snapshot
var snapshotRegion = new CGRect (offset, 0f, foldWidth, size.Height);
snapshotView = view.ResizableSnapshotView (snapshotRegion, afterUpdates, UIEdgeInsets.Zero);
} else {
// for the to- view for some reason the snapshot takes a while to create. Here we place the snapshot within
// another view, with the same bckground color, so that it is less noticeable when the snapshot initially renders
snapshotView = new UIView (new CGRect (0f, 0f, foldWidth, size.Height));
snapshotView.BackgroundColor = view.BackgroundColor;
var snapshotRegion = new CGRect (offset, 0f, foldWidth, size.Height);
UIView snapshotView2 = view.ResizableSnapshotView (snapshotRegion, afterUpdates, UIEdgeInsets.Zero);
snapshotView.AddSubview (snapshotView2);
}
// create a shadow
UIView snapshotWithShadowView = AddShadowToView (snapshotView, left);
// add to the container
containerView.AddSubview (snapshotWithShadowView);
// set the anchor to the left or right edge of the view
snapshotWithShadowView.Layer.AnchorPoint = new CGPoint (left ? 0f : 1f, 0.5f);
return snapshotWithShadowView;
}