GKPictureInPictureView 0.2.0

GKPictureInPictureView 0.2.0

Gruber Kristóf 维护。



GKPictureInPictureView

Version License Platform

可拖动、可调整大小,可放置在屏幕边缘的视图。类似于 FaceTime 和 PiP。

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

// 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];

Example

要求

iOS 10

安装

GKPictureInPictureView 可通过 CocoaPods 使用。要安装它,只需将以下行添加到您的 Podfile 中

pod 'GKPictureInPictureView'

用法

可以由代码初始化GKPictureInPictureView(可参考上面的示例)或使用Storyboard来使用。

代码

  1. 创建您的视图内容。它将被限制在可拖拽视图的边缘,所以不要添加任何可能与大小或位置冲突的约束。
  2. 创建一个GKPictureInPictureView并使用-initWithContentView:初始化。
  3. 将其添加到您的父视图:使用-addToSuperView:animated:

Storyboard

  1. 创建一个UIView。您可以创建任何子视图,但不要设置任何与宽度、高度和位置相关的约束。
  2. 将视图的类更改为GKPictureInPictureView

微调

有许多选项可以选择。例如,您可以设置如bottomLeftPositionEnabled选项为NO来防止视图移到特定的边缘。您也可以禁用缩放。更多详情请参见GKPictureInPictureView.h头文件。

作者

gklka,[email protected]

许可证

GKPictureInPictureView是在MIT许可证下可用的。有关更多信息,请参阅LICENSE文件。