I make a simple calculator, the screen is divided into two parts: on top - the scoreboard with the result, on the bottom - the keyboard (I create it myself from different buttons). I plan to fasten the svayp (moving your finger left / right), this movement does not move the entire screen, and the keyboard changes with the usual actions (multiplication, division) on the keyboard with advanced operations. Here's how to make a similar UIView so that when you swipe, only the bottom of the screen changes? This is obviously a few UIViews to create, and how can they be glued together then?

UPDATE :

It seems to have figured out, I don’t know how correct it is, but here’s the code, who can come in handy:

containerView.translatesAutoresizingMaskIntoConstraints = false containerView.pagingEnabled = true redView.translatesAutoresizingMaskIntoConstraints = false containerView.addSubview(redView) greenView.translatesAutoresizingMaskIntoConstraints = false containerView.addSubview(greenView) let views = [ "greenView" : greenView, "redView" : redView, "view" : containerView ] view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[redView(==view)]|", options: [], metrics: nil, views: views)) view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[greenView(==view)]|", options: [], metrics: nil, views: views)) view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[redView(==view)][greenView(==view)]|", options: [], metrics: nil, views: views)) 

Where containerView is UIScrollView

redView and greenView - UIView

  • one
    You need to self.view two subviews each the size of the screen floor to your controller's self.view: the top one is a calculator, and the bottom one is UIScrollView with pagingEnabled. To do this I twist the size to be two screens wide, on the first one clave, on the second the other. Everything. - Max Mikheyenko

1 answer 1

Add both keyboards to the bottom half of the screen. Simple put on the screen (x = 0). You put the extended one on the left (off screen): x = -vc.view.frame.size.width

With the svaype (UISwipeGestureRecognizer) from the left to the right of the extended keyboard you put x = 0, and i = x vc.view.frame.size.width. You change in the [UIView animateWithDuration: 0.3 block animations: ^ {}];

Keyboard width is always = vc.view.frame.size.width.