Draggable, sizeable view which can placed in screen edges. Similar to FaceTime and PiP.
To run the example project, clone the repo, and run pod install
from the Example directory first.
// Your gorgeous content view
UIView *contentView = [UIView new];
contentView.backgroundColor = [UIColor redColor];
// Init Picture in Picture view
self.pipView = [[GKPictureInPictureView alloc] initWithContentView:contentView];
// Show it
[self.pipView addToSuperView:self.blue animated:YES];
iOS 10
GKPictureInPictureView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'GKPictureInPictureView'
GKPictureInPictureView can be used either by initializing it from code (see the Example above) or by using Storyboards.
- Create your content view. It will be constrainted to the draggable view's edges, so don't add any constraints which can conflict with the size or position
- Create a GKPictureInPictureView and init it with
-initWithContentView:
- Add it to your superview:
-addToSuperView:animated:
.
- Create a
UIView
. You can create whatever subviews you want, but don't set any constraints to width, height and position - Change the class of the view to
GKPictureInPictureView
There are plenty of options you can choose from. For example you can prevent the view to go to certain edges by setting NO on options like bottomLeftPositionEnabled
. You can also disable zooming. See GKPictureInPictureView.h headers for details.
gklka, gk@lka.hu
GKPictureInPictureView is available under the MIT license. See the LICENSE file for more info.