/* 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(); }
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"); }
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); }
/// <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 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; } }
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 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)); }
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); }
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 FlipImageAnimated(bool animated) { UIView.BeginAnimations("flipImage"); UIView.SetAnimationDuration(animated ? 0.18f : 0f); arrowImage.Layer.Transform = isFlipped ? CATransform3D.MakeRotation(3.141593f, 0f, 0f, 1f) : CATransform3D.MakeRotation(3.141593f * 2, 0f, 0f, 1f); UIView.CommitAnimations(); isFlipped = !isFlipped; }
public Animation Transform3DAnimation(AnimatedView view, int time) { var animationFrame = Animation.CountKeyFrames(time); if (animationFrame == null) { return(this); } CGRect nativeViewSize = new CGRect(view.X, view.Y, view.Width, view.Height); UIView nativeView = ConvertFormsToNative(view, nativeViewSize); AnimationFrame aFrame = (AnimationFrame)Animation.AnimationFrameForTime(time); if (aFrame.Transform == null) { return(null); } CATransform3D transform = CATransform3D.Identity; transform.m34 = aFrame.Transform.M34; transform = CATransform3D.MakeRotation( aFrame.Transform.Rotate.Angle, aFrame.Transform.Rotate.X, aFrame.Transform.Rotate.Y, aFrame.Transform.Rotate.Z); // Scale transform.m11 = aFrame.Transform.Scale.Sx; transform.m22 = aFrame.Transform.Scale.Sy; transform.m33 = aFrame.Transform.Scale.Sz; // Translate transform.m41 = aFrame.Transform.Translate.Tx; transform.m42 = aFrame.Transform.Translate.Ty; transform.m43 = aFrame.Transform.Translate.Tz; // transform.Rotate ( // aFrame.Transform.Rotate.Angle, // aFrame.Transform.Rotate.X, // aFrame.Transform.Rotate.Y, // aFrame.Transform.Rotate.Z); // transform.Scale ( // aFrame.Transform.Scale.Sx, // aFrame.Transform.Scale.Sy, // aFrame.Transform.Scale.Sz); // // transform.Translate ( // aFrame.Transform.Translate.Tx, // aFrame.Transform.Translate.Ty, // aFrame.Transform.Translate.Tz); nativeView.Layer.Transform = transform; return(this); }
public override void LayoutSublayersOfLayer(CALayer layer) { base.LayoutSublayersOfLayer(layer); if (layer == null || layer != this.Layer) { return; } var offset = CGPoint.Empty; var radius = Math.Min(Bounds.Width, Bounds.Height) / 2 - (_lineWidth / 2); offset.X = (nfloat)(Bounds.Width - radius * 2) / 2; offset.Y = (nfloat)(Bounds.Height - radius * 2) / 2; CATransaction.Begin(); CATransaction.DisableActions = true; // Calculate frame for circle and trail circle var circleAndTrailFrame = new CGRect(offset.X, offset.Y, radius * 2, radius * 2); var circlePath = UIBezierPath.FromOval(circleAndTrailFrame); trailCircle.Path = circlePath.CGPath; circle.Transform = CATransform3D.Identity; circle.Frame = this.Bounds; circle.Path = UIBezierPath.FromOval(circleAndTrailFrame).CGPath; // Rotating circle by 212 degrees to be able to manipulate stroke end location. circle.Transform = CATransform3D.MakeRotation((float)(212 * Math.PI / 180), 0, 0, 1); var origin = new CGPoint(offset.X + radius, offset.Y + radius); // Calculate checkmark path var checkmarkPath = UIBezierPath.Create(); var checkmarkStartPoint = CGPoint.Empty; // Checkmark will start from circle's stroke end calculated above. checkmarkStartPoint.X = (nfloat)(origin.X + radius * ((float)(Math.Cos(212 * Math.PI / 180)))); checkmarkStartPoint.Y = (nfloat)(origin.Y + radius * ((float)(Math.Sin(212 * Math.PI / 180)))); checkmarkPath.MoveTo(checkmarkStartPoint); checkmarkSplitPoint = new CGPoint(offset.X + radius * 0.9, offset.Y + radius * 1.4); checkmarkPath.AddLineTo(checkmarkSplitPoint); var checkmarkEndPoint = CGPoint.Empty; // Checkmark will end 320 degrees location of the circle layer. checkmarkEndPoint.X = (nfloat)(origin.X + radius * (float)(Math.Cos(320 * Math.PI / 180))); checkmarkEndPoint.Y = (nfloat)(origin.Y + radius * (float)(Math.Sin(320 * Math.PI / 180))); checkmarkPath.AddLineTo(checkmarkEndPoint); checkmark.Frame = this.Bounds; checkmark.Path = checkmarkPath.CGPath; CATransaction.Commit(); }
public void RotateXYZ60Transform() { UIView.Animate( duration: 2, animation: () => { dogView.Layer.Transform = CATransform3D.MakeRotation( (float)Math.PI / 3, 1, 1, 1); }); }
private CATransform3D YawTransform(nfloat yawAngle) { var radians = yawAngle.ToRadians(); var yawTransform = CATransform3D.MakeRotation(radians, 0.0f, -1.0f, 0.0f); var orientationTransform = OrientationTransform(); return(orientationTransform.Concat(yawTransform)); }
void SetupLayers() { if (view == null || view.Bounds.Size.IsEmpty) { return; } RemoveLayers(); // replicator layer replicatorLayer = new CAReplicatorLayer(); replicatorLayer.Frame = view.Bounds; replicatorLayer.InstanceCount = finCount; replicatorLayer.PreservesDepth = false; replicatorLayer.InstanceColor = color.CGColor; var angle = (nfloat)(Math.PI * 2.0 / (double)finCount); replicatorLayer.InstanceTransform = CATransform3D.MakeRotation(angle, 0, 0, 1); if (view.Layer == null) { view.Layer = new CALayer(); } view.Layer.AddSublayer(replicatorLayer); view.WantsLayer = true; // instance layer var layerHeight = Math.Min(view.Bounds.Width, view.Bounds.Height) * finSizeMultiplier; var layerWidth = layerHeight * finAspectRatio; var midX = view.Bounds.GetMidX() - layerWidth / 2.0; var instanceLayer = new CALayer(); instanceLayer.Frame = new CGRect(midX, 0, layerWidth, layerHeight); instanceLayer.BackgroundColor = color.CGColor; instanceLayer.CornerRadius = (nfloat)(layerWidth / 2.0); instanceLayer.Bounds = new CGRect(CGPoint.Empty, new CGSize(layerWidth, layerHeight)); replicatorLayer.AddSublayer(instanceLayer); // fade animation var fadeAnimation = CABasicAnimation.FromKeyPath("opacity"); fadeAnimation.From = NSNumber.FromDouble(1.0); fadeAnimation.To = NSNumber.FromDouble(0); fadeAnimation.RepeatCount = float.MaxValue; //set layer fade animation instanceLayer.Opacity = 0; fadeAnimation.Duration = revolutionDuration; instanceLayer.AddAnimation(fadeAnimation, "FadeAnimation"); replicatorLayer.InstanceDelay = revolutionDuration / (double)finCount; }
public override void TouchesMoved(NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); UITouch touch = touches.AnyObject as UITouch; CGPoint point = touch.LocationInView(View); box.Layer.Transform = CATransform3D.Identity; box.Frame = new Rectangle((int)(point.X + BoxStride) / 2, (int)(point.Y + BoxStride) / 2, BoxStride, BoxStride); box.Layer.Transform = CATransform3D.MakeRotation((float)(angle / 180.0 * Math.PI), 0, 0, 1); }
public void Flip(bool animate) { UIView.BeginAnimations(null); UIView.SetAnimationDuration(animate ? .18f : 0); arrowView.Layer.Transform = IsFlipped ? CATransform3D.MakeRotation((float)Math.PI, 0, 0, 1) : CATransform3D.MakeRotation((float)Math.PI * 2, 0, 0, 1); UIView.CommitAnimations(); IsFlipped = !IsFlipped; }
public DragMoreView(RectangleF rect, bool isHeader) : base(rect) { this.isHeader = isHeader; this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; ReleaseLabelText = !isHeader ? "Release to load more" : "Release to refresh"; PullLabelText = !isHeader ? "Pull up to load more" : "Pull down to refresh..."; LoadingLabelText = "Loading..."; LastUpdateLabelText = "Last Updated: {0:g}"; BackgroundColor = new UIColor(0.88f, 0.9f, 0.92f, 1); 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 = this.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 = this.BackgroundColor, Opaque = true, TextAlignment = UITextAlignment.Center, AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin }; AddSubview(statusLabel); SetStatus(RefreshViewStatus.PullToReload); arrowView = new UIImageView() { ContentMode = UIViewContentMode.ScaleAspectFill, Image = arrow, 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); }
private CATransform3D Rotate(float angle) { if (TurnDiresction == CEDirection.Horizontal) { return(CATransform3D.MakeRotation(angle, 1f, 0f, 0f)); } else { return(CATransform3D.MakeRotation(angle, 0f, 1f, 0f)); } }
private void StartRotationTimer() { timer = NSTimer.CreateRepeatingScheduledTimer(0.001, delegate { angle += 2.0f; if (angle >= 360.0f) { angle = 0.0f; } box.Layer.Transform = CATransform3D.MakeRotation((float)(angle / 180.0 * Math.PI), 0, 0, 1); }); }
public void stopLoading() { isLoading = false; UIView.Animate(0.3f, () => { this.TableView.ContentInset = UIEdgeInsets.Zero; refreshArrow.Layer.Transform = CATransform3D.MakeRotation((nfloat)Math.PI * 2, (nfloat)0, (nfloat)0, (nfloat)1); }, () => { this.PerformSelector(new Selector("stopLoadingComplete")); }); }
public override void AwakeFromNib() { base.AwakeFromNib(); ClipsToBounds = true; GradientLayer = new CAGradientLayer { Locations = new NSNumber[] { 0, 1 }, // Rotate gradient to be horizontal Transform = CATransform3D.MakeRotation(-NMath.PI / 2, 0, 0, 1) }; Layer.InsertSublayer(GradientLayer, 0); }
public async Task RotationInitializeCorrectly(float rotation) { var view = new TStub() { Rotation = rotation, }; var transform = await GetLayerTransformAsync(view); var expected = CATransform3D.MakeRotation(rotation * (float)Math.PI / 180.0f, 0, 0, 1); expected.AssertEqual(transform); }
public RefreshTableHeaderView(RectangleF rect, bool isTop) : base(rect) { this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; PullMessage = "Pull Down to Refresh..."; ReleaseMessage = "Release to refresh"; BackgroundColor = new UIColor(0.88f, 0.9f, 0.92f, 1); 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 = this.BackgroundColor, Opaque = true, TextAlignment = UITextAlignment.Center, AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin | (isTop ? UIViewAutoresizing.FlexibleBottomMargin : UIViewAutoresizing.FlexibleTopMargin) }; 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 = this.BackgroundColor, Opaque = true, TextAlignment = UITextAlignment.Center, Lines = 0, AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin }; AddSubview(statusLabel); SetStatus(RefreshViewStatus.PullToReload); arrowView = new UIImageView() { ContentMode = UIViewContentMode.ScaleAspectFill, Image = arrow, 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); }
public override void Animate(int time) { if (KeyFrames.Count() <= 1) { return; } AnimationFrame aFrame = (AnimationFrame)AnimationFrameForTime(time); if (aFrame.Transform == null) { return; } CATransform3D transform = CATransform3D.Identity; transform.m34 = aFrame.Transform.M34; transform = CATransform3D.MakeRotation( aFrame.Transform.Rotate.Angle, aFrame.Transform.Rotate.X, aFrame.Transform.Rotate.Y, aFrame.Transform.Rotate.Z); // Scale transform.m11 = aFrame.Transform.Scale.Sx; transform.m22 = aFrame.Transform.Scale.Sy; transform.m33 = aFrame.Transform.Scale.Sz; // Translate transform.m41 = aFrame.Transform.Translate.Tx; transform.m42 = aFrame.Transform.Translate.Ty; transform.m43 = aFrame.Transform.Translate.Tz; // transform.Rotate ( // aFrame.Transform.Rotate.Angle, // aFrame.Transform.Rotate.X, // aFrame.Transform.Rotate.Y, // aFrame.Transform.Rotate.Z); // transform.Scale ( // aFrame.Transform.Scale.Sx, // aFrame.Transform.Scale.Sy, // aFrame.Transform.Scale.Sz); // // transform.Translate ( // aFrame.Transform.Translate.Tx, // aFrame.Transform.Translate.Ty, // aFrame.Transform.Translate.Tz); this.View.Layer.Transform = transform; }
/// <summary> /// Closes all cells. /// </summary> public void Close() { Closing?.Invoke(this, EventArgs.Empty); // rotate plus icon CATransaction.AnimationDuration = 0.8; plusLayer.Transform = CATransform3D.MakeRotation(0, 0, 0, 1); baseView.Close(CellArray()); IsClosed = true; Closed?.Invoke(this, EventArgs.Empty); }
private void setLoadingViewStyle(UITableView t) { return; vLoading = new UIView(new RectangleF(0, 0 - this.View.Bounds.Size.Height, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height)); vLoading.BackgroundColor = UIColor.FromRGB(225, 235, 239); vLoading.Layer.MasksToBounds = true; vLoading.Layer.CornerRadius = 0.0f; UILabel lblTitle = new UILabel() { Font = UIFont.FromName("Helvetica Neue", 14), TextColor = UIColor.FromRGB(25, 119, 156), BackgroundColor = UIColor.Clear }; //frame.size.height - 48.0f, 320.0f, 20.0f lblTitle.Frame = new RectangleF(0, vLoading.Frame.Height - 50, 320, 40); lblTitle.Layer.MasksToBounds = false; lblTitle.Layer.ShadowOffset = new SizeF(0, 1); lblTitle.Layer.ShadowOpacity = 0.5f; lblTitle.Opaque = true; lblTitle.TextAlignment = UITextAlignment.Center; lblTitle.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; lblTitle.Text = "Pull to Refresh..."; vLoading.AddSubview(lblTitle); var imgViewArrow = new UIImageView(UIImage.FromBundle("images/ic_menu_down.png")); imgViewArrow.Frame = new RectangleF(25, vLoading.Frame.Height - 65f, 30, 55); imgViewArrow.ContentMode = UIViewContentMode.ScaleAspectFit; imgViewArrow.Layer.MasksToBounds = true; imgViewArrow.Layer.Transform = CATransform3D.MakeRotation(3.14159265358979323846264338327950288f, 0f, 0f, 1f); vLoading.AddSubview(imgViewArrow); vLoading.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; this.tblMain.AddSubview(vLoading); }
public RefreshTableHeaderView() : base() { this.BackgroundColor = new UIColor(226f, 231f, 237f, 1f); lastUpdatedLabel = new UILabel(new RectangleF(0f, this.Frame.Height - 30f, 320f, 20f)); lastUpdatedLabel.Font = UIFont.SystemFontOfSize(12f); lastUpdatedLabel.TextColor = UIColor.Black; lastUpdatedLabel.ShadowColor = UIColor.FromWhiteAlpha(0.9f, 1f); lastUpdatedLabel.ShadowOffset = new SizeF(0f, 1f); lastUpdatedLabel.BackgroundColor = UIColor.Clear; lastUpdatedLabel.TextAlignment = UITextAlignment.Center; if (NSUserDefaults.StandardUserDefaults["EGORefreshTableView_LastRefresh"] != null) { lastUpdatedLabel.Text = NSUserDefaults.StandardUserDefaults["EGORefreshTableView_LastRefresh"].ToString(); } else { SetCurrentDate(); } this.AddSubview(lastUpdatedLabel); statusLabel = new UILabel(new RectangleF(0f, this.Frame.Height - 48f, 320f, 20f)); statusLabel.Font = UIFont.BoldSystemFontOfSize(13f); statusLabel.TextColor = UIColor.Black; //new UIColor (87.0f,108.0f,137.0f,1.0f); statusLabel.ShadowColor = UIColor.FromWhiteAlpha(0.9f, 1f); statusLabel.ShadowOffset = new SizeF(0f, 1f); statusLabel.BackgroundColor = UIColor.Clear; statusLabel.TextAlignment = UITextAlignment.Center; SetStatus(RefreshTableHeaderView.RefreshStatus.PullToReloadStatus); this.AddSubview(statusLabel); arrowImage = new UIImageView(new RectangleF(25f, this.Frame.Height - 65f, 30f, 55f)); arrowImage.Image = UIImage.FromFile("blueArrow.png"); arrowImage.ContentMode = UIViewContentMode.ScaleAspectFit; arrowImage.Layer.Transform = CATransform3D.MakeRotation(3.141593f, 0f, 0f, 1f); this.AddSubview(arrowImage); activityView = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray); activityView.Frame = new RectangleF(25f, this.Frame.Height - 38f, 20f, 20f); activityView.HidesWhenStopped = true; this.AddSubview(activityView); this.isFlipped = false; }