public override void ViewDidLoad() { base.ViewDidLoad(); this.View.BackgroundColor = UIColor.FromRGB(22, 22, 22); var text = new NSString("Begin"); var size = MeasureTextSize(text, this.View.Frame.Width, _fontSize, _fontName); _fontHeight = (float)size.Height; var frame = new Rectangle(new Point(0, (int)(this.View.Frame.Height / 2f - _fontHeight)), new Size((int)this.View.Frame.Width, 96)); // Perform any additional setup after loading the view, typically from a nib. _begin = new UILabel(frame) { Text = "Begin", TextColor = UIColor.White, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0), Font = UIFont.FromName(_fontName, _fontSize), Alpha = 0, ShadowColor = UIColor.FromRGBA(255, 255, 255, 125), ShadowOffset = Size.Empty }; _currentTile = new MazeTile(Movements2D.Left | Movements2D.Backward | Movements2D.Forward | Movements2D.Right) { Frame = this.View.Frame, Alpha = 0 }; this.View.Add(_currentTile); this.View.Add(_begin); _swipeUp = new UISwipeGestureRecognizer(SwipedUp) { Direction = UISwipeGestureRecognizerDirection.Up }; _swipeDown = new UISwipeGestureRecognizer(SwipedDown) { Direction = UISwipeGestureRecognizerDirection.Down }; _swipeLeft = new UISwipeGestureRecognizer(SwipedLeft) { Direction = UISwipeGestureRecognizerDirection.Left }; _swipeRight = new UISwipeGestureRecognizer(SwipedRight) { Direction = UISwipeGestureRecognizerDirection.Right }; _currentTile.AddGestureRecognizer(_swipeUp); _currentTile.AddGestureRecognizer(_swipeDown); _currentTile.AddGestureRecognizer(_swipeLeft); _currentTile.AddGestureRecognizer(_swipeRight); }
public override void ViewDidLayoutSubviews() { if (_lastFrame == CGRect.Empty) { _lastFrame = this.View.Frame; } base.ViewDidLayoutSubviews(); var textTop = this.View.Frame.Height / 2f - _fontHeight / 2f; var textFrame = new Rectangle(new Point(0, (int)textTop), new Size((int)this.View.Frame.Width, 96)); if (_nextTile != null) { UIView.Animate(0.75, 0, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseInOut, () => { _nextTile.Frame = this.View.Frame; _currentTile.Frame = _currentFrame; //_currentTile.Center = new CGPoint( _currentFrame.Width /2f, -_currentFrame.Height/2f); }, () => { _currentTile = _nextTile; _currentTile.AddGestureRecognizer(_swipeUp); _currentTile.AddGestureRecognizer(_swipeDown); _currentTile.AddGestureRecognizer(_swipeLeft); _currentTile.AddGestureRecognizer(_swipeRight); }); } else { UIView.Animate(2, 1, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseOut, () => { _begin.Alpha = 1.0f; _begin.Frame = textFrame; _currentTile.Alpha = 1.0f; }, null); _hasRun = true; } // if (_hasRun && _lastFrame.Width == this.View.Frame.Width) { // _currentTile.Frame = this.View.Frame; // _begin.Frame = textFrame; // } _lastFrame = this.View.Frame; }
public override void ViewDidLayoutSubviews() { if (_lastFrame == CGRect.Empty) _lastFrame = this.View.Frame; base.ViewDidLayoutSubviews (); var textTop = this.View.Frame.Height / 2f - _fontHeight / 2f; var textFrame = new Rectangle (new Point (0, (int)textTop), new Size ((int)this.View.Frame.Width, 96)); if (_nextTile != null) { UIView.Animate (0.75, 0, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseInOut, () => { _nextTile.Frame = this.View.Frame; _currentTile.Frame = _currentFrame; //_currentTile.Center = new CGPoint( _currentFrame.Width /2f, -_currentFrame.Height/2f); }, () => { _currentTile = _nextTile; _currentTile.AddGestureRecognizer (_swipeUp); _currentTile.AddGestureRecognizer (_swipeDown); _currentTile.AddGestureRecognizer (_swipeLeft); _currentTile.AddGestureRecognizer (_swipeRight); }); } else { UIView.Animate (2, 1, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseOut, () => { _begin.Alpha = 1.0f; _begin.Frame = textFrame; _currentTile.Alpha = 1.0f; }, null); _hasRun = true; } // if (_hasRun && _lastFrame.Width == this.View.Frame.Width) { // _currentTile.Frame = this.View.Frame; // _begin.Frame = textFrame; // } _lastFrame = this.View.Frame; }
public override void ViewDidLoad() { base.ViewDidLoad (); this.View.BackgroundColor = UIColor.FromRGB (22, 22, 22); var text = new NSString ("Begin"); var size = MeasureTextSize (text, this.View.Frame.Width, _fontSize, _fontName); _fontHeight = (float)size.Height; var frame = new Rectangle (new Point (0, (int)(this.View.Frame.Height / 2f - _fontHeight)), new Size ((int)this.View.Frame.Width, 96)); // Perform any additional setup after loading the view, typically from a nib. _begin = new UILabel (frame) { Text = "Begin", TextColor = UIColor.White, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromRGBA(0,0,0,0), Font = UIFont.FromName(_fontName, _fontSize), Alpha = 0, ShadowColor = UIColor.FromRGBA(255,255,255,125), ShadowOffset = Size.Empty }; _currentTile = new MazeTile (Movements2D.Left | Movements2D.Backward | Movements2D.Forward | Movements2D.Right) { Frame = this.View.Frame, Alpha = 0 }; this.View.Add (_currentTile); this.View.Add (_begin); _swipeUp = new UISwipeGestureRecognizer (SwipedUp){ Direction = UISwipeGestureRecognizerDirection.Up }; _swipeDown = new UISwipeGestureRecognizer (SwipedDown){ Direction = UISwipeGestureRecognizerDirection.Down }; _swipeLeft = new UISwipeGestureRecognizer (SwipedLeft){ Direction = UISwipeGestureRecognizerDirection.Left }; _swipeRight = new UISwipeGestureRecognizer (SwipedRight){ Direction = UISwipeGestureRecognizerDirection.Right }; _currentTile.AddGestureRecognizer (_swipeUp); _currentTile.AddGestureRecognizer (_swipeDown); _currentTile.AddGestureRecognizer (_swipeLeft); _currentTile.AddGestureRecognizer (_swipeRight); }