/// <summary> /// Close the Modal Window and removes it from Super View /// </summary> public void Close() { NSNotificationCenter.DefaultCenter.RemoveObserver(this, "UIDeviceOrientationDidChangeNotification", null); CATransform3D currentTransform = this.dialogView.Layer.Transform; nfloat startRotation = nfloat.Parse(this.ValueForKeyPath(new NSString("layer.transform.rotation.z")).ToString()); CATransform3D rotation = CATransform3D.MakeRotation((nfloat)(-startRotation + Math.PI * 270 / 180), 0, 0, 0); CATransform3D scale = CATransform3D.MakeScale((nfloat)1, (nfloat)1, 1); this.dialogView.Layer.Transform = currentTransform.Concat(scale); this.dialogView.Layer.Opacity = 1; UIView.Animate(0.2, 0, UIViewAnimationOptions.TransitionNone, () => { this.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0); this.dialogView.Layer.Transform = currentTransform.Concat(CATransform3D.MakeScale((nfloat)0.6, (nfloat)0.6, 1)); this.dialogView.Layer.Opacity = 0; }, () => { foreach (UIView v in this.Subviews) { v.RemoveFromSuperview(); } this.RemoveFromSuperview(); this.SetupViews(); }); }
public void animation2(Button button) { var scaleAnimation = CABasicAnimation.FromKeyPath("transform"); scaleAnimation.From = NSValue.FromCATransform3D(CATransform3D.MakeScale(1, 1, 1)); scaleAnimation.To = NSValue.FromCATransform3D(CATransform3D.MakeScale(2, 2, 1)); var opacityAnimation = CABasicAnimation.FromKeyPath("opacity"); opacityAnimation.From = NSNumber.FromFloat(0.25f); opacityAnimation.To = NSNumber.FromFloat(0.0f); var rippleAnimationGroup = new CAAnimationGroup { Duration = 2.0f, TimeOffset = -0.25f, RemovedOnCompletion = true, FillMode = CAFillMode.Both, TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut), Animations = new CAAnimation[] { scaleAnimation, opacityAnimation } }; rippleCircleLayer.AddAnimation(rippleAnimationGroup, "rippleMyAnimations"); }
public void DidScroll(UIScrollView scrollView) { if (isLoading) { if (scrollView.ContentOffset.Y > 0) { this.TableView.ContentInset = UIEdgeInsets.Zero; } else if (scrollView.ContentOffset.Y >= -REFRESH_HEADER_HEIGHT) { this.TableView.ContentInset = new UIEdgeInsets(-scrollView.ContentOffset.Y, 0, 0, 0); } } else if (isDragging && scrollView.ContentOffset.Y < 0) { UIView.Animate(0.25, () => { if (scrollView.ContentOffset.Y < -REFRESH_HEADER_HEIGHT) { // User is scrolling above the header refreshLabel.Text = this.textRelease; refreshArrow.Layer.Transform = CATransform3D.MakeRotation((nfloat)Math.PI, (nfloat)0.0f, (nfloat)0.0f, (nfloat)1.0f); } else { refreshLabel.Text = this.textPull; refreshArrow.Layer.Transform = CATransform3D.MakeRotation((nfloat)Math.PI * 2, (nfloat)0.0f, (nfloat)0.0f, (nfloat)1.0f); } }); } }
private void CreateLines(CGRect lineFrame, CGPoint imgCenterPoint) { var path = new CGPath(); path.MoveToPoint(new CGPoint(lineFrame.GetMidX(), lineFrame.GetMidY())); path.AddLineToPoint(new CGPoint(lineFrame.X + lineFrame.Width / 2, lineFrame.Y)); _lines = new CAShapeLayer[5]; for (int i = 0; i < 5; i++) { var line = new CAShapeLayer() { Bounds = lineFrame, Position = imgCenterPoint, MasksToBounds = true, Actions = new NSDictionary("strokeStart", new NSNull(), "strokeEnd", new NSNull()), StrokeColor = _lineColor.CGColor, LineWidth = 1.25F, MiterLimit = 1.25F, Path = path, LineCap = CAShapeLayer.CapRound, LineJoin = CAShapeLayer.JoinRound, StrokeStart = 0.0F, StrokeEnd = 0.0F, Opacity = 0.0F, Transform = CATransform3D.MakeRotation((nfloat)Math.PI / 5F * (nfloat)(i * 2F + 1), 0.0F, 0.0F, 1.0F) }; this.Layer.AddSublayer(line); _lines[i] = line; } }
private void CreateCircleShape(CGRect imageFrame, CGPoint imgCenterPoint) { _circleShape = new CAShapeLayer() { Bounds = imageFrame, Position = imgCenterPoint, Path = UIBezierPath.FromOval(imageFrame).CGPath, FillColor = _circleColor.CGColor, Transform = CATransform3D.MakeScale(0.0F, 0.0F, 1.0F) }; this.Layer.AddSublayer(_circleShape); _circleMask = new CAShapeLayer() { Bounds = imageFrame, Position = imgCenterPoint, FillRule = CAShapeLayer.FillRuleEvenOdd }; _circleShape.Mask = _circleMask; var maskPath = UIBezierPath.FromRect(imageFrame); maskPath.AddArc(imgCenterPoint, 0.1F, 0.0F, (System.nfloat)(Math.PI * 2F), true); _circleMask.Path = maskPath.CGPath; }
public void HideAnimated(bool animated, Action completion) { CATransaction.Begin(); { CATransaction.CompletionBlock = () => { completion?.Invoke(); Layer.Transform = CATransform3D.Identity; }; if (animated) { Layer.AnimateKey(new NSString("transform"), null, NSValue.FromCATransform3D(CATransform3D.MakeScale(0.5f, 0.5f, 1)), (animation) => { animation.Duration = 0.55; animation.TimingFunction = CAMediaTimingFunction.FromControlPoints(0.1f, -2, 0.3f, 3); }); Layer.AnimateKey(new NSString("opacity"), null, NSObject.FromObject(0.0), (animation) => { animation.Duration = 0.75; }); } else // not animated - just set opacity to 0.0 { Layer.Opacity = 0.0f; } } CATransaction.Commit(); }
/// <summary> /// Show the Modal Picker. /// </summary> /// <param name="title">Window Title.</param> /// <param name="doneButtonTitle">Done button title.</param> /// <param name="cancelButtonTitle">Cancel button title.</param> /// <param name="callback">Callback that return selected value in Picker.</param> public void Show(string title, string doneButtonTitle, string cancelButtonTitle, Action <K> callback) { this.OnValueSelected = callback; this.titleLabel.Text = title; this.doneButton?.SetTitle(doneButtonTitle, UIControlState.Normal); if (this.showCancelButton) { this.cancelButton.SetTitle(cancelButtonTitle, UIControlState.Normal); } var del = UIApplication.SharedApplication.Delegate; var window = del.GetWindow(); window.AddSubview(this); window.BringSubviewToFront(this); window.EndEditing(true); NSNotificationCenter.DefaultCenter.AddObserver(new NSString("UIDeviceOrientationDidChangeNotification"), (NSNotification obj) => { CGSize screenSize = this.CountScreenSize(); CGSize dialogSize = new CGSize(300, 230 + kDefaultButtonHeight + kDefaultButtonSpacerHeight); this.Frame = new CGRect(0, 0, screenSize.Width, screenSize.Height); dialogView.Frame = new CGRect((screenSize.Width - dialogSize.Width) / 2.0, (screenSize.Height - dialogSize.Height) / 2.0, dialogSize.Width, dialogSize.Height); }); Animate(0.2, 0.0, UIViewAnimationOptions.CurveEaseInOut, () => { this.BackgroundColor = UIColor.FromRGBA(0, 0, 0, (nfloat)0.4); this.dialogView.Layer.Opacity = 1; this.dialogView.Layer.Transform = CATransform3D.MakeScale(1, 1, 1); }, () => { }); }
public override void ViewWillAppear(bool animated) { base.ViewDidAppear(animated); //Creates basic moving animation var pt = layer.Position; layer.Position = new CGPoint(100, 300); var basicAnimation = CABasicAnimation.FromKeyPath("position"); basicAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut); basicAnimation.From = NSValue.FromCGPoint(pt); basicAnimation.To = NSValue.FromCGPoint(new CGPoint(100, 300)); //Creates transformation animation layer.Transform = CATransform3D.MakeRotation((float)Math.PI * 2, 0, 0, 1); var animRotate = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath("transform"); animRotate.Values = new NSObject[] { NSNumber.FromFloat(0f), NSNumber.FromFloat((float)Math.PI / 2f), NSNumber.FromFloat((float)Math.PI), NSNumber.FromFloat((float)Math.PI * 2) }; animRotate.ValueFunction = CAValueFunction.FromName(CAValueFunction.RotateX); //Adds the animations to a group, and adds the group to the layer var animationGroup = CAAnimationGroup.CreateAnimation(); animationGroup.Duration = 2; animationGroup.Animations = new CAAnimation[] { basicAnimation, animRotate }; layer.AddAnimation(animationGroup, null); }
void animateLabelBack() { CATransaction.Begin(); CATransaction.CompletionBlock = () => { this.label.TextColor = this.kDefaultInactiveColor; }; var anim2 = CABasicAnimation.FromKeyPath("transform"); var fromTransform = CATransform3D.MakeScale(0.5f, 0.5f, 1); fromTransform = fromTransform.Translate(-this.label.Frame.Width / 2, -this.label.Frame.Height, 0); var toTransform = CATransform3D.MakeScale(1, 1, 1); anim2.From = NSValue.FromCATransform3D(fromTransform); anim2.To = NSValue.FromCATransform3D(toTransform); anim2.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); var animGroup = new CAAnimationGroup(); animGroup.Animations = new CAAnimation[] { anim2 }; animGroup.Duration = 0.3; animGroup.FillMode = CAFillMode.Forwards; animGroup.RemovedOnCompletion = false; this.label.Layer.AddAnimation(animGroup, "_animateLabelBack"); CATransaction.Commit(); }
public void Constructor_CATransform3d() { var transform = new CATransform3D() { M11 = 11, M12 = 12, M13 = 13, M14 = 14, M21 = 21, M22 = 22, M23 = 23, M24 = 24, M31 = 31, M32 = 32, M33 = 33, M34 = 34, M41 = 41, M42 = 42, M43 = 43, M44 = 44, }; var matrix = new SCNMatrix4(transform); AssertEqual(matrix, "Constructor", 11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44); }
protected virtual void UpdateNativeWidget() { if (layer == null) { layer = Layer; } if (inputTransparent != node.InputTransparent) { UserInteractionEnabled = !node.InputTransparent; inputTransparent = node.InputTransparent; } Frame = new RectangleF((float)node.X, (float)node.Y, (float)node.Width, (float)node.Height); layer.AnchorPoint = new PointF((float)node.AnchorX, (float)node.AnchorY); layer.Opacity = (float)node.Opacity; CATransform3D transform = CATransform3D.Identity; transform = transform.Scale((float)node.Scale); transform.m34 = 1.0f / -400f; transform = transform.Rotate((float)node.Rotation * (float)Math.PI / 180.0f, 0.0f, 0.0f, 1.0f); transform = transform.Rotate((float)node.RotationX * (float)Math.PI / 180.0f, 1.0f, 0.0f, 0.0f); transform = transform.Rotate((float)node.RotationY * (float)Math.PI / 180.0f, 0.0f, 1.0f, 0.0f); layer.Transform = transform; SetNeedsDisplay(); }
protected void FloatLabelBack() { CATransaction.Begin(); CATransaction.CompletionBlock = () => { Label.TextColor = LabelInactiveTextColor; }; var animation = CABasicAnimation.FromKeyPath("transform"); var fromTransform = CATransform3D.MakeScale(.5f, .5f, 1); var toTransform = CATransform3D.MakeScale(1, 1, 1); fromTransform = fromTransform.Translate(-Label.Frame.Width * 0.5f, -Label.Frame.Height, 0); animation.From = NSValue.FromCATransform3D(fromTransform); animation.To = NSValue.FromCATransform3D(toTransform); animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); var animationGroup = new CAAnimationGroup { Animations = new CAAnimation[] { animation }, Duration = .3f, FillMode = CAFillMode.Forwards, RemovedOnCompletion = false }; Label.Layer.AddAnimation(animationGroup, "_floatLabelBack"); ClipsToBounds = false; CATransaction.Commit(); }
public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath) { #region Set animation when Display Data if (!Variables.ViewWillAppear) { //1. Set the initial state of the cell cell.Alpha = 0; var transform = CATransform3D.MakeTranslation(-250, 20, 0); cell.Layer.Transform = transform; //2. UIView animation method to change to the final state of the cell UIView.Animate(0.5, () => { cell.Alpha = 1; cell.Layer.Transform = CATransform3D.Identity; }); } if (indexPath.Row == tableView.IndexPathsForVisibleRows[tableView.IndexPathsForVisibleRows.Length - 1].LongRow) { var lastrow = tableView.IndexPathsForVisibleRows[tableView.IndexPathsForVisibleRows.Length - 1].LongRow; Variables.ViewWillAppear = false; } #endregion }
void CreateKeyframeAnimation() { // animate the position PointF fromPt = _sublayer.Position; _sublayer.Position = new PointF(200, 300); CGPath path = new CGPath(); path.AddLines(new PointF[] { fromPt, new PointF(250, 225), new PointF(100, 250), new PointF(200, 300) }); CAKeyFrameAnimation animPosition = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath("position"); animPosition.Path = path; animPosition.Duration = 2; _sublayer.AddAnimation(animPosition, "position"); // animate the layer transform _sublayer.Transform = CATransform3D.MakeRotation((float)Math.PI, 0, 0, 1); CAKeyFrameAnimation animRotate = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath("transform"); animRotate.Values = new NSObject[] { NSNumber.FromCATransform3D(CATransform3D.MakeRotation(0, 0, 0, 1)), NSNumber.FromCATransform3D(CATransform3D.MakeRotation((float)Math.PI / 2f, 0, 0, 1)), NSNumber.FromCATransform3D(CATransform3D.MakeRotation((float)Math.PI, 0, 0, 1)) }; /* see bug comment below * animRotate.Values = new NSObject[] { * NSNumber.FromFloat (0f), * NSNumber.FromFloat ((float)Math.PI / 2f), * NSNumber.FromFloat ((float)Math.PI) }; */ //BUG: MonoTouch does not have this class method bound as of MonoTouch Versino 3.1.3 //animRotate.ValueFunction = CAValueFunction.FunctionWithName(CAValueFunction.RotateZ); animRotate.Duration = 2; _sublayer.AddAnimation(animRotate, "transform"); }
void UpdateTransforms() { leftTransform = CATransform3D.Identity; leftTransform = leftTransform.Rotate(sideCoverAngle, 0, 1, 0); rightTransform = CATransform3D.Identity; rightTransform = rightTransform.Rotate(sideCoverAngle, 0, -1, 0); }
private CATransform3D OrientationTransform() { nfloat angle = 0.0f; switch (UIDevice.CurrentDevice.Orientation) { case UIDeviceOrientation.PortraitUpsideDown: angle = (nfloat)Math.PI; break; case UIDeviceOrientation.LandscapeRight: angle = (nfloat)(-Math.PI / 2.0f); break; case UIDeviceOrientation.LandscapeLeft: angle = (nfloat)Math.PI / 2.0f; break; default: angle = 0.0f; break; } return(CATransform3D.MakeRotation(angle, 0.0f, 0.0f, 1.0f)); }
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect(CGRect rect) { var array = base.LayoutAttributesForElementsInRect(rect); var visibleRect = new CGRect(CollectionView.ContentOffset, CollectionView.Bounds.Size); int collectionViewCount = (int)this.CollectionView.NumberOfItemsInSection(0); foreach (var attributes in array) { if (collectionViewCount == 1) { float zoom = 1 + ZOOM_FACTOR; attributes.Transform3D = CATransform3D.MakeScale(zoom, zoom, 1.0f); attributes.ZIndex = 1; } if (attributes.Frame.IntersectsWith(rect) && (collectionViewCount != 2 && collectionViewCount != 3)) { float distance = (float)(visibleRect.GetMidX() - attributes.Center.X); float normalizedDistance = distance / ACTIVE_DISTANCE; if (Math.Abs(distance) < ACTIVE_DISTANCE) { float zoom = 1 + ZOOM_FACTOR * (1 - Math.Abs(normalizedDistance)); attributes.Transform3D = CATransform3D.MakeScale(zoom, zoom, 1.0f); attributes.ZIndex = 1; } } } return(array); }
public Camera(Layer parent) : base(parent) { CALayer preview = CameraLayer; if (preview != null) { Layer.AddSublayer(preview); preview.Position = new CGPoint(160, 309); preview.Bounds = new CGRect(preview.Bounds.Location.X, preview.Bounds.Location.Y, 320, 320f * 16 / 9); preview.Transform = CATransform3D.MakeRotation((nfloat)Math.PI, 0f, 1f, 0f); var previewMask = new CALayer(); Layer.AddSublayer(previewMask); previewMask.Position = new CGPoint(160, 260); previewMask.Bounds = new CGRect(previewMask.Bounds.Location.X, previewMask.Bounds.Location.Y, 320f, 320f); previewMask.BackgroundColor = CreateColor(0, 0, 0, 255); preview.Mask = previewMask; } else { Layer fakePreview = new Layer(this); fakePreview.LoadImage("toast.jpg"); fakePreview.Width = fakePreview.Height = 320; fakePreview.Y = Screen.GlobalScreen.Height * 0.5f - fakePreview.Height * 0.5f; } }
private UICollectionViewLayoutAttributes TransformLayoutAttributes(UICollectionViewLayoutAttributes attributes) { if (CollectionView == null) { return(attributes); } var isHorizontal = ScrollDirection == UICollectionViewScrollDirection.Horizontal; var collectionCenter = isHorizontal ? CollectionView.Frame.Size.Width / 2 : CollectionView.Frame.Size.Height / 2; var offset = isHorizontal ? CollectionView.ContentOffset.X : CollectionView.ContentOffset.Y; var normalizedCenter = (isHorizontal ? attributes.Center.X : attributes.Center.Y) - offset; var maxDistance = (isHorizontal ? ItemSize.Width : ItemSize.Height) + MinimumLineSpacing; var distance = Math.Min(Math.Abs(collectionCenter - normalizedCenter), maxDistance); var ratio = (float)((maxDistance - distance) / maxDistance); var alpha = ratio * (1 - SideItemAlpha) + SideItemAlpha; var scale = ratio * (1 - SideItemScale) + SideItemScale; var shift = (1 - ratio) * SideItemShift; attributes.Alpha = alpha; attributes.Transform3D = CATransform3D.MakeScale(scale, scale, 1); attributes.ZIndex = (int)(alpha * 10); attributes.Center = isHorizontal ? new CGPoint(attributes.Center.X, attributes.Center.Y + shift) : new CGPoint(attributes.Center.X + shift, attributes.Center.Y); return(attributes); }
private UIViewController ChangeRootViewController(UIViewController viewController) { if (Window.RootViewController == null) { Window.RootViewController = viewController; return(null); } var oldRootController = Window.RootViewController; var snapShot = Window.SnapshotView(true); viewController.View.AddSubview(snapShot); Window.RootViewController = viewController; UIView.Animate(0.5, () => { snapShot.Layer.Opacity = 0; snapShot.Layer.Transform = CATransform3D.MakeScale(1.5f, 1.5f, 1.5f); }, () => { snapShot.RemoveFromSuperview(); }); return(oldRootController); }
/* Dialog close animation then cleaning and removing the view from the parent */ private void Close() { var currentTransform = _dialogView.Layer.Transform; var startRotation = (this.ValueForKeyPath(new NSString("layer.transform.rotation.z")) as NSNumber); var startRotationAngle = startRotation.DoubleValue; var rotation = CATransform3D.MakeRotation((nfloat)(-startRotationAngle + Math.PI * 270 / 180d), 0f, 0f, 0f); _dialogView.Layer.Transform = rotation.Concat(CATransform3D.MakeScale(1, 1, 1)); _dialogView.Layer.Opacity = 1; UIView.Animate(0.2, 0d, UIViewAnimationOptions.TransitionNone, () => { BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0); _dialogView.Layer.Transform = currentTransform.Concat(CATransform3D.MakeScale(0.6f, 0.6f, 1f)); _dialogView.Layer.Opacity = 0; }, () => { var subViews = this.Subviews.ToArray(); foreach (UIView v in subViews) { v.RemoveFromSuperview(); } }); this.RemoveFromSuperview(); }
public unsafe void TestStructMarshaling() { var random = new Random(); var twoRegistersResult = NSString.stringWithString_("First second third").rangeOfString_("second"); Assert.AreEqual(6, twoRegistersResult.location); Assert.AreEqual(6, twoRegistersResult.length); var originalMatrix = new CATransform3D(); float *originalMatrixPtr = &originalMatrix.m11; for (int i = 0; i < 16; i++) { originalMatrixPtr[i] = ( float )random.NextDouble(); } var newMatrix = QuartzCoreExtensionsOfNSValue.valueWithCATransform3D_(originalMatrix).CATransform3DValue(); float *newMatrixPtr = &newMatrix.m11; Console.WriteLine(); for (int i = 0; i < 16; i++) { //Assert.AreEqual( originalMatrixPtr[i], newMatrixPtr[i] ); Assert.AreEqual((&originalMatrix.m11)[i], (&newMatrix.m11)[i]); } }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.Black; mainTabBar.Items.Each((UITabBarItem item, int index) => { item.BadgeValue = "Normal"; foreach (var badgeView in mainTabBar.Subviews[index].Subviews) { if (index > 0) { if (badgeView.Class.Name.Contains("_UIBadgeView")) { badgeView.Layer.Transform = new CATransform3D(); badgeView.Layer.Transform = CATransform3D.MakeTranslation(-100, -20, 1); item.BadgeValue = "Custom"; item.BadgeColor = UIColor.Green; item.SetBadgeTextAttributes(new UIStringAttributes() { ForegroundColor = UIColor.Black }, UIControlState.Normal); return; } } } }); }
void CreateAnimationGroup() { PointF fromPt = _sublayer.Position; _sublayer.Position = new PointF(200, 300); CGPath path = new CGPath(); path.AddLines(new PointF[] { fromPt, new PointF(250, 225), new PointF(100, 250), new PointF(200, 300) }); CAKeyFrameAnimation animPosition = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath("position"); animPosition.Path = path; _sublayer.Transform = CATransform3D.MakeRotation((float)Math.PI, 0, 0, 1); CAKeyFrameAnimation animRotate = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath("transform"); animRotate.Values = new NSObject[] { NSNumber.FromCATransform3D(CATransform3D.MakeRotation(0, 0, 0, 1)), NSNumber.FromCATransform3D(CATransform3D.MakeRotation((float)Math.PI / 2f, 0, 0, 1)), NSNumber.FromCATransform3D(CATransform3D.MakeRotation((float)Math.PI, 0, 0, 1)) }; CAAnimationGroup spinningMonkeyGroup = CAAnimationGroup.CreateAnimation(); spinningMonkeyGroup.Duration = 2; spinningMonkeyGroup.Animations = new CAAnimation[] { animPosition, animRotate }; _sublayer.AddAnimation(spinningMonkeyGroup, null); }
void floatLabelToTop(bool changeColor = true) { CATransaction.Begin(); CATransaction.CompletionBlock = () => { if (changeColor) { this.label.TextColor = this.kDefaultActiveColor; } }; var anim2 = CABasicAnimation.FromKeyPath("transform"); var fromTransform = CATransform3D.MakeScale(1, 1, 1); var toTransform = CATransform3D.MakeScale(0.5f, 0.5f, 1); toTransform = toTransform.Translate(-this.label.Frame.Width / 2, -this.label.Frame.Height, 0); anim2.From = NSValue.FromCATransform3D(fromTransform); anim2.To = NSValue.FromCATransform3D(toTransform); anim2.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); var animGroup = new CAAnimationGroup(); animGroup.Animations = new CAAnimation[] { anim2 }; animGroup.Duration = 0.3; animGroup.FillMode = CAFillMode.Forwards; animGroup.RemovedOnCompletion = false; this.label.Layer.AddAnimation(animGroup, "_floatingLabel"); this.ClipsToBounds = false; CATransaction.Commit(); }
public async Task TransformationCalculatedCorrectly() { var view = new TStub() { TranslationX = 10.0, TranslationY = 30.0, Rotation = 248.0, Scale = 2.0, ScaleX = 2.0, }; var transform = await GetLayerTransformAsync(view); var expected = new CATransform3D { M11 = -1.4984f, M12 = -3.7087f, M21 = 1.8544f, M22 = -0.7492f, M33 = 2f, M41 = 10f, M42 = 30f, M44 = 1f, }; expected.AssertEqual(transform); }
private void Initialize() { AutoresizingMask = UIViewAutoresizing.FlexibleWidth; BackgroundColor = new UIColor(0.88f, 0.9f, 0.92f, 1); BackgroundColor = UIColor.Red; _LastUpdateLabel = new UILabel() { Font = UIFont.SystemFontOfSize(13f), TextColor = new UIColor(0.47f, 0.50f, 0.57f, 1), ShadowColor = UIColor.White, ShadowOffset = new SizeF(0, 1), BackgroundColor = BackgroundColor, Opaque = true, TextAlignment = UITextAlignment.Center, AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin }; AddSubview(_LastUpdateLabel); _StatusLabel = new UILabel() { Font = UIFont.BoldSystemFontOfSize(14), TextColor = new UIColor(0.47f, 0.50f, 0.57f, 1), ShadowColor = _LastUpdateLabel.ShadowColor, ShadowOffset = new SizeF(0, 1), BackgroundColor = BackgroundColor, Opaque = true, TextAlignment = UITextAlignment.Center, AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin }; AddSubview(_StatusLabel); SetStatus(RefreshStatus.PullToReload); _ArrowView = new UIImageView() { ContentMode = UIViewContentMode.ScaleAspectFill, Image = _ArrowImage, AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin }; _ArrowView.Layer.Transform = CATransform3D.MakeRotation((float)Math.PI, 0, 0, 1); AddSubview(_ArrowView); _Activity = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray) { HidesWhenStopped = true, AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin }; AddSubview(_Activity); if (NSUserDefaults.StandardUserDefaults[_DefaultSettingsKey] != null) { LastUpdate = Convert.ToDateTime(NSUserDefaults.StandardUserDefaults[_DefaultSettingsKey].ToString()); } else { LastUpdate = DateTime.MinValue; } }
/// <summary> /// Touchs up animation. /// </summary> public void TouchUpAnimation() { foreach (UIImageView Icon in IconArray) { UIView.AnimateNotify(0.1f, 0.0f, UIViewAnimationOptions.BeginFromCurrentState, () => { Icon.Alpha = 0.0f; } , (finished) => { Icon.Hidden = true; }); } var ButtonScaleSmallCABasicAnimation = CABasicAnimation.FromKeyPath(@"transform.scale"); ButtonScaleSmallCABasicAnimation.Duration = 0.2f; ButtonScaleSmallCABasicAnimation.AutoReverses = false; ButtonScaleSmallCABasicAnimation.To = NSNumber.FromFloat(1.0f); ButtonScaleSmallCABasicAnimation.From = NSNumber.FromFloat(BigRadius / SmallRadius); ButtonScaleSmallCABasicAnimation.FillMode = CAFillMode.Forwards; ButtonScaleSmallCABasicAnimation.RemovedOnCompletion = false; SmallButton.Layer.AddAnimation(ButtonScaleSmallCABasicAnimation, @"ButtonScaleSmallCABasicAnimation"); var BackgroundViewScaleSmallCABasicAnimation = CABasicAnimation.FromKeyPath(@"transform.scale"); BackgroundViewScaleSmallCABasicAnimation.Duration = 0.1f; BackgroundViewScaleSmallCABasicAnimation.AutoReverses = false; BackgroundViewScaleSmallCABasicAnimation.To = NSNumber.FromFloat(1.0f); BackgroundViewScaleSmallCABasicAnimation.From = NSNumber.FromNFloat(this.Frame.Size.Height / SmallRadius); BackgroundViewScaleSmallCABasicAnimation.FillMode = CAFillMode.Forwards; BackgroundViewScaleSmallCABasicAnimation.RemovedOnCompletion = false; BackgroundView.Layer.AddAnimation(BackgroundViewScaleSmallCABasicAnimation, @"BackgroundViewScaleSmallCABasicAnimation"); var Rotate = CATransform3D.MakeRotation(0, 0, 1, 0).Concat(CATransform3D.MakeRotation(0, 1, 0, 0)); if (Parallex) { SmallButton.Layer.Transform = CATransform3DPerspect(Rotate, new CGPoint(0, 0), BigRadius + ParallexParameter); } else { //Do nothing ^_^ } SmallButton.SetImage(IconImage, UIControlState.Normal); UIView.AnimateNotify(0.1f, 0.0f, UIViewAnimationOptions.BeginFromCurrentState, () => { SmallButton.ImageView.Alpha = 1.0f; } , (finished) => { }); }
public void NavigateToUnsafe(Page page, object parameter) { System.Diagnostics.Debug.WriteLine($"Navigate to {page.ToString()} in thread {Thread.CurrentThread.ManagedThreadId.ToString()}"); lock (pagesByKey) { Type type; if (pagesByKey.ContainsKey(page)) { type = pagesByKey[page].Type; } else { throw new InvalidOperationException($"Unable to navigate: page {page.ToString()} not found"); } if (!CrossConnectivity.Current.IsConnected) { var dialogService = ServiceLocator.Current.GetInstance <IDialogService>(); dialogService.ShowMessage(LocalizedStrings.ConnectionError, LocalizedStrings.Error); return; } if (pagesByKey[page].RequireAuth) { var accountManager = ServiceLocator.Current.GetInstance <IAccountManager>(); if (!accountManager.IsAuthorized()) { NavigateTo(Page.SignInPage); return; } } UIViewController uIViewController; uIViewController = CreateController(page, parameter); if (pagesByKey[page].IsRoot) { UIView snapShot = AppDelegate.Instance.Window.SnapshotView(false); AppDelegate.Instance.Window.RootViewController = new TransparentNavigationController(uIViewController); if (snapShot != null) { uIViewController.View.AddSubview(snapShot); UIView.AnimateNotify(0.3f, () => { snapShot.Layer.Opacity = 0; snapShot.Layer.Transform = CATransform3D.MakeScale(1.5f, 1.5f, 1.5f); }, (finished) => snapShot.RemoveFromSuperview()); } } else if (NavigationController.TopViewController == null || !NavigationController.Contains(uIViewController)) { this.NavigationController.PushViewController(uIViewController, true); } } }
void animationLinear(int i, float offset) { var transform = CATransform3D.Identity; var mx = (float)(1.0 - offset) * 100; transform = CATransform3D.MakeTranslation(mx * subsWeights[i].X, mx * subsWeights[i].Y, 0); applyTransform(i, transform); }
void UpdateTransforms() { leftTransform = CATransform3D.Identity; leftTransform = leftTransform.Rotate (sideCoverAngle, 0, 1, 0); rightTransform = CATransform3D.Identity; rightTransform = rightTransform.Rotate (sideCoverAngle, 0, -1, 0); }